333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
 
<template>
  <div ref="container" class="page-list-container">
    <yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :button-click="buttonClick" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes" :fixed-where="fixedWhere" @on-load-dropdown-after="onLoadDropdownAfter" @on-super-reset="onSuperReset">
      <template slot="button-tool2-slot">
        <el-select v-model="storage_Id" placeholder="请选择仓库" class="w-150" @change="onSelectChange">
          <el-option v-for="(item, index) in storageList" :key="index" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
        <el-select v-model="consignor_Id" placeholder="请选择货主" class="w-150" @change="onSelectChange">
          <el-option v-for="(item, index) in consignorList" :key="index" :label="item.label" :value="item.value">
          </el-option>
        </el-select>
        <el-button type="primary" @click.native="inventoryting()">生成盘点单</el-button>
      </template>
    </yrt-data-list>
 
    <el-dialog :visible.sync="dialogFormVisible" title="生成盘点数据" width="500px">
      <el-form :model="form" :label-width="formLabelWidth">
        <el-form-item label="仓库名称" class="no-margin">
          {{ storageName }}
        </el-form-item>
        <el-form-item label="货主" class="margin-bottom-10">
          {{ consignorName }}
        </el-form-item>
        <el-form-item label="盘点类型">
          <el-select v-model="form.checkType" filterable clearable placeholder="请选择盘点类型" @change="currentSel">
            <el-option v-for="item in checkTypeList" :key="item.id" :label="item.name" :value="item.name">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="是否盲盘">
          <el-checkbox v-model="form.checked"></el-checkbox>
        </el-form-item>
        <el-form-item v-if="isdifference" label="差异天数" style="width:320px;">
          <el-input v-model="form.input" :disabled="!isdifference" type="text" placeholder="请输天数"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible=false">取 消</el-button>
        <el-button type="primary" @click="confirmsubmit">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
 
<script>
import baseLayout from "@/components/common/base-layout.vue";
 
export default {
  name: "storage-check-create-check",
  components: {},
  mixins: [baseLayout],
  data() {
    return {
      id: "",
      name: "",
      isdifference: false, // 差异天数
      checkTypeList: [], // 盘点类型
      actionField: "",
      dialogFormVisible: false,
 
      storage_Id: null, // 选择仓库
      consignor_Id: null, // 货主
      storageName: null,
      consignorName: null,
 
      form: {
        checkType: "常规盘",
        input: "",
        name: "",
        region: "",
        date1: "",
        date2: "",
        delivery: false,
        type: [],
        resource: "",
        desc: "",
        checked: false
      },
      formLabelWidth: "120px",
      // 仓库下拉框数据列表
      storageList: [],
      // 货主下拉框数据列表
      consignorList: [],
      // 固定查询条件
      fixedWhere: {}
    };
  },
  computed: {},
  created() {
    this.loadCheckType();
  },
  activated() {
    // SaaS模块权限
    this.common.hasSaaSAuth("库存盘点", this.$refs.container);
  },
  methods: {
    onLoadDropdownAfter(dropdownData) {
      this.storageList = dropdownData["dropdown31"];
      this.consignorList = dropdownData["dropdown797"];
    },
    currentSel(value) {
      this.isdifference = false;
      if (value === "动态盘") {
        this.isdifference = true;
      }
    },
    // 确定生成盘点单数据的
    confirmsubmit() {
      var storage_Id = this.storage_Id;
      var consignor_Id = this.consignor_Id;
      var where = this.getWhere();
      var checkType = this.form.checkType;
      var diffDate = this.form.input;
      var ids = this.dataListSelections.map(item => item.productPosition_Id); // 选中ID
      var isBlind = this.form.checked === true ? 1 : 0;
      if (!diffDate) diffDate = 0;
      if (!checkType) {
        this.$message({
          showClose: true,
          message: "请输入盘点类型",
          type: "error"
        });
        return;
      }
      if (checkType === "动态盘" && !diffDate) {
        this.$message({
          showClose: true,
          message: "请输入差异天数",
          type: "error"
        });
        return;
      }
      const url = "/api/storage/check/storageCheck";
      let params = {
        storage_Id: storage_Id,
        consignor_Id: consignor_Id,
        checkType: checkType,
        diffDate: diffDate,
        IsBlind: isBlind,
        ids: ids,
        idField: "productPosition_Id"
      };
      params = Object.assign(params, where);
      const ref = this.dataList;
      var callback = res => {
        this.common.showMsg(res);
        if (res.result) {
          ref.loadData();
        }
      };
      this.common.ajax(url, params, callback, ref);
 
      this.dialogFormVisible = false;
    },
    getWhere() {
      var storage_Id = this.storage_Id;
      var consignor_Id = this.consignor_Id;
      var _where = this.dataList.getAllWhere();
      var fixedWhere = {};
      if (storage_Id) {
        fixedWhere.storage_Id = storage_Id;
      }
      if (consignor_Id) {
        fixedWhere.consignor_Id = consignor_Id;
      }
 
      var where = {
        fixedWhere: fixedWhere,
        where: _where
      };
 
      return where;
    },
    loadCheckType() {
      const url = "/api/storage/check/dropdown";
      const params = {};
      const callback = res => {
        if (res.result) {
          this.checkTypeList = res.data; // 盘点类型
        }
      };
      this.common.ajax(url, params, callback);
    },
    // 校验并弹出输入页面
    inventoryting() {
      if (!this.storage_Id) {
        this.$message.error("请选择仓库");
        return;
      }
      if (!this.consignor_Id) {
        this.$message.error("请选择货主");
        return;
      }
      this.consignorName = this.consignorList.find(item => {
        return item.consignor_Id === this.consignor_Id;
      }).consignorName;
 
      // 弹出框
      this.dialogFormVisible = true;
    },
    // 改变仓库、货主
    onSelectChange() {
      var where = {};
      if (this.storage_Id) {
        this.storageName = this.storageList.find(item => {
          return item.storage_Id === this.storage_Id;
        }).storageName;
        where.storage_Id = this.storage_Id;
      }
      if (this.consignor_Id) {
        this.consignorName = this.consignorList.find(item => {
          return item.consignor_Id === this.consignor_Id;
        }).consignorName;
        where.consignor_Id = this.consignor_Id;
      }
      this.fixedWhere = where;
      this.$nextTick(() => {
        this.dataList.loadData();
      });
    },
    // 重置
    onSuperReset() {
      this.storage_Id = null;
      this.consignor_Id = null;
    }
  }
};
</script>