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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<template>
  <div class="page-list-container">
    <!--数据Table-->
    <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">
 
    </yrt-data-list>
 
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" :btn-read-only="btnReadOnly" :default-value="defaultValue" :edit-button-click="editButtonClick" :on-save-before="onSaveBefore" @on-change="onChange" @on-edit-load-after="onEditLoadAfter" @on-add-load-after="onEditLoadAfter">
    </yrt-editor>
 
    <!--出库明细选择器-->
    <yrt-selector ref="selector-dialog" :config="selectorConfig" :visible.sync="selectorConfig.visible" :set-search-default="setSearchDefault" @on-selected="onSelected"></yrt-selector>
    <!--入库明细选择器-->
    <yrt-selector ref="selectorEnter-dialog" :config="selectorEnterConfig" :visible.sync="selectorEnterConfig.visible" :set-search-default="setSearchDefault" @on-selected="onEnterSelected"></yrt-selector>
    <!--套餐选择器-->
    <yrt-selector ref="selectorTC-dialog" :config="selectorTCConfig" :visible.sync="selectorTCConfig.visible" :set-search-default="setSearchDefault" @on-selected="onTCSelected"></yrt-selector>
 
    <el-dialog :visible.sync="dialogPositionName">
      <el-form :model="form">
        <el-form-item label="货位名称">
          <el-input ref="positionName" v-model="form.positionName" class="input-300" autofocus @keyup.native.enter.stop="getData"></el-input>
        </el-form-item>
        <el-button style="margin-left: 10px;" size="small" type="success" @click="updatepositionName()">保存明细货位</el-button>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import baseLayout from "@/components/common/base-layout.vue";
import yrtSelector from "@/components/common/yrtSelector.vue";
 
export default {
  name: "/storage/check/assemble",
  components: { yrtSelector },
  mixins: [baseLayout],
  data() {
    return {
      dialogPositionName: false,
      selectorConfig: {
        title: "物料选择器",
        width: "1000px",
        visible: false,
        // 配置路由
        router: "/selector/s-product-selector"
      },
      selectorEnterConfig: {
        title: "物料选择器",
        width: "1000px",
        visible: false,
        // 配置路由
        router: "/selector/s-product-selector"
      },
      selectorTCConfig: {
        title: "物料选择器",
        width: "1000px",
        visible: false,
        // 配置路由
        router: "/selector/sale_order_productSplit"
      },
      form: {
        positionName: ""
      },
      // 表单默认值,新建时用
      defaultValue: {
        statusID: 1,
        statusText: "新建",
        sortingStatus: "未分配",
        auditing: 0
      },
      // 自动加载预到货单字段
      editorData: [
        "consignor_Id",
        "storageName",
        "DeptName",
        "ApplyDate",
        "providerShortName",
        "ShippingName",
        "ShippingAddress",
        "Mobile",
        "storage_Id"
      ]
    };
  },
  methods: {
    // 列表页面按钮点击事件
    buttonClick(authNode) {},
    // 明细按钮点击事件
    detailButtonClick(authNode) {
      switch (authNode) {
        case "add":
          // 明细添加
          this.selectorConfig.visible = true;
          break;
        case "detailAdd":
          // 明细添加
          this.selectorEnterConfig.visible = true;
          return false;
        case "btnEnter":
          // btnEnter
          this.selectorTCConfig.visible = true;
          break;
        case "btnPosition":
          // 修改入库明细货位
          this.dialogPositionName = true;
          break;
      }
    },
    // 编辑按钮点击事件
    editButtonClick(authNode) {
      switch (authNode) {
        case "auditing":
          // 审核
          this.auditing();
          return false;
      }
    },
    // 保存入库明细货位
    updatepositionName() {
      var the = this;
      const ref = the.dataList;
      const assembleEnterList_Ids = this.editor.detailFields[1].options.detailSelections.map((item, index, Array) => {
        return item.assembleEnterList_Id;
      });
      const assemble_Id = the.dataOptions.idValue;
      var url = "/api/storage/check/updatepositionName";
      the.initLoading = true;
      var params = {
        positionName: this.form.positionName,
        assembleEnterList_Id: assembleEnterList_Ids,
        assemble_Id: assemble_Id
      };
      the.common.ajax(
        url,
        params,
        res => {
          if (res.result) {
            the.$message.success(res.msg);
            ref.loadData();
            the.editorOptions.config.visible = false;
          } else {
            the.$message({
              showClose: true,
              duration: 6000,
              message: res.msg,
              type: "error"
            });
          }
          the.dialogPositionName = false;
        },
        true
      );
    },
    // 将选择器选择中的数据填充到明细表中
    onSelected(rows) {
      this.editor.addDetailDataRow(rows);
      this.selectorConfig.visible = false;
    },
    showTCdate() {
      this.selectorConfig.visible = true;
    },
    onEnterSelected(rows) {
      this.editor.addDetailDataRow(rows, "Storage_AssembleEnterList");
      this.selectorEnterConfig.visible = false;
    },
    onTCSelected(rows) {
      this.editor.addDetailDataRow(rows, "Storage_AssembleEnterList");
      this.selectorTCConfig.visible = false;
    },
    auditing(formData) {
      // 判断入库明细货位不能为空
      let IsPositionName = false;
      this.editor.formData["Storage_AssembleEnterList"].rows.forEach(item => {
        if (!IsPositionName) {
          if (!item.positionName) {
            IsPositionName = true;
          }
        }
      });
      if (IsPositionName) {
        this.$message({
          type: "error",
          message: "入库明细货位不可为空"
        });
        return false;
      }
 
      var the = this;
      this.$confirm("审核后将无法进行修改, 是否继续?", "审核操作", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          _auditing();
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消审核"
          });
        });
      function _auditing() {
        var formData = the.editor.formData;
        var dbServer = "Sys";
        var idField = the.dataOptions.idField;
        var idValue = formData[the.dataOptions.idField];
        var tableName = the.dataOptions.tableView;
 
        const ref = the.dataList;
        var url = "/api/storage/storageAdjust/auditingAssemble";
        the.initLoading = true;
        var params = {
          dbServer: dbServer,
          idField: idField,
          idValue: idValue,
          tableName: tableName,
          auditing: 2
        };
        the.common.ajax(
          url,
          params,
          res => {
            if (res.result) {
              the.$message.success(res.msg);
              ref.loadData();
              the.editorOptions.config.visible = false;
            } else {
              the.$message({
                showClose: true,
                duration: 6000,
                message: res.msg,
                type: "error"
              });
            }
            the.initLoading = false;
          },
          true
        );
      }
    },
    // 数据加载后
    onEditLoadAfter(formData) {
      var auditing = formData.auditing;
      if (auditing === 2) {
        // 审核成功
        this.btnReadOnly.save = true;
        this.btnReadOnly.stop = true;
        this.btnReadOnly.open = false;
        this.btnReadOnly.auditing = true;
        this.editorOptions.config.disabled = true; // 整个对话框不可编辑
      } else {
        this.btnReadOnly.save = false;
        this.btnReadOnly.stop = false;
        this.btnReadOnly.open = false;
        this.btnReadOnly.auditing = false;
        this.editorOptions.config.disabled = false; // 整个对话框可编辑
      }
    },
    // 主表数据改变
    onChange(ref, val, field, formData) {},
    // 对选择器默认值操作
    setSearchDefault(searchData) {},
    // 求和
    setTotal() {
      // 合计出库数量
      let outerQuantity = 0;
      // 合计入库数量
      let enterQuantity = 0;
 
      this.editor.formData["Storage_AssembleOuterList"].rows.forEach(item => {
        // 明细金额 = 数量 * 单价;
        // item.purchaseMoney = Math.Round((item.quantity || 0) * (item.purchasePrice || 0), 2);
        // 行重量
        // item.totalWeight = Math.Round((item.quantity || 0) * (item.weight || 0), 2);
 
        outerQuantity += item.outerQuantity || 0;
      });
 
      this.editor.formData["Storage_AssembleEnterList"].rows.forEach(item => {
        enterQuantity += item.enterQuantity || 0;
      });
 
      this.editor.changeValue("totalOuterQuantity", parseInt(outerQuantity));
      this.editor.changeValue("totalEnterQuantity", parseInt(enterQuantity));
    },
    // 保存前事件
    onSaveBefore() {
      return this.setTotal();
    }
  }
};
</script>