Warehouse.vue 48.3 KB
Newer Older
lanbaoming's avatar
lanbaoming committed
1
<template>
zs嵩's avatar
zs嵩 committed
2
  <div style="display: inline-block; margin-right: 10px">
lanbaoming's avatar
lanbaoming committed
3
    <el-button size="mini" @click="visible = true" type="text">{{ title }}</el-button>
zs嵩's avatar
zs嵩 committed
4
    <el-dialog :title="title + ' - ' + warehousing.orderNo" :visible.sync="visible" width="100%">
lanbaoming's avatar
lanbaoming committed
5 6 7 8 9
      <el-tabs v-model="activeName" type="card">
        <el-tab-pane :label="edit ? $t('货物修改') : $t('货物入仓')" name="first">
          <el-form ref="form" :model="form" :rules="formRules" label-width="80px">
            <el-descriptions border :column="2">
              <el-descriptions-item>
zs嵩's avatar
zs嵩 committed
10 11 12
                <template slot="label"><span style="color: red">*</span>{{ $t("中文品名") }}</template>
                <span style="min-width: 200px; margin-right: 15px; display: inline-block">
                  <product-selector v-if="(!order.parentOrderId && !isAdd) || order.splitSeparateOrder" v-model="form.prodId" @change="onProductChange" determined protect-once />
lanbaoming's avatar
lanbaoming committed
13 14 15 16 17
                  <span v-else>{{ warehousing.prodTitleZh }}</span>
                </span>
                <el-button v-if="(!order.parentOrderId && !isAdd) || order.splitSeparateOrder" type="text" @click="isShowProduct = true">添加新商品</el-button>
              </el-descriptions-item>
              <el-descriptions-item>
zs嵩's avatar
zs嵩 committed
18 19
                <template slot="label"><span style="color: red">*</span>{{ $t("英文品名") }}</template>
                <product-selector v-if="(!order.parentOrderId && !isAdd) || order.splitSeparateOrder" lang="En" v-model="form.prodId" @change="onProductChange" determined protect-once />
lanbaoming's avatar
lanbaoming committed
20 21 22
                <span v-else>{{ warehousing.prodTitleEn }}</span>
              </el-descriptions-item>
              <el-descriptions-item :label="$t('品牌')">
zs嵩's avatar
zs嵩 committed
23
                <template slot="label"><span style="color: red">*</span>{{ $t("品牌") }}</template>
lanbaoming's avatar
lanbaoming committed
24
                <el-form-item required label="" prop="brand" label-width="0">
zs嵩's avatar
zs嵩 committed
25 26
                  <el-select v-model="form.brand" :placeholder="$t('可修改')" filterable remote @change="handleBrandChange" :remote-method="getProductBrandPage" clearable>
                    <el-option v-for="item in brandList" :key="item.id" :label="item.titleZh" :value="item.id"> </el-option>
lanbaoming's avatar
lanbaoming committed
27 28 29 30
                  </el-select>
                </el-form-item>
              </el-descriptions-item>
              <el-descriptions-item :label="$t('是否备案')">
zs嵩's avatar
zs嵩 committed
31
                <template slot="label"><span style="color: red">*</span>{{ $t("是否备案") }}</template>
lanbaoming's avatar
lanbaoming committed
32 33 34
                {{ isBeian }}
              </el-descriptions-item>
              <el-descriptions-item :label="$t('收费模式')">
zs嵩's avatar
zs嵩 committed
35
                <template slot="label"><span style="color: red">*</span>{{ $t("收费模式") }}</template>
lanbaoming's avatar
lanbaoming committed
36 37
                {{ feeType }}
              </el-descriptions-item>
zs嵩's avatar
zs嵩 committed
38 39 40 41 42
              <el-descriptions-item :label="$t('填单参数')"
                >{{ $t("箱数:") }}<el-input size="mini" v-if="edit" v-model="warehousing.num" style="display: inline-block; width: 100px"></el-input> <span v-else>{{ warehousing.num }}</span
                ><br />{{ $t("体积:") }}<el-input size="mini" v-if="edit" v-model="warehousing.volume" style="display: inline-block; width: 100px"></el-input> <span v-else>{{ warehousing.volume }}</span
                ><br />{{ $t("重量:") }}<el-input size="mini" v-if="edit" v-model="warehousing.weight" style="display: inline-block; width: 100px"></el-input> <span v-else>{{ warehousing.weight }}</span
                >Kg
lanbaoming's avatar
lanbaoming committed
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
              </el-descriptions-item>
            </el-descriptions>
            <el-row>
              <el-col :span="8">
                <el-form-item :label="$t('材质')" style="margin-top: 20px">
                  <dict-selector :type="DICT_TYPE.ECW_PRODUCT_MATERIAL" v-model="form.material" clearable></dict-selector>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item :label="$t('入仓特性')" style="margin-top: 20px">
                  <el-checkbox-group v-model="form.warehouseInProdAttrIds">
                    <el-checkbox v-for="item in attrList" :key="item.id" :label="item.id">{{ item.attrName }}</el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item :label="$t('入仓时间')" v-if="!edit">
                  <el-date-picker v-model="form.inTime" type="datetime" :placeholder="$t('请选择入仓时间')" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item :label="$t('用途')">
                  <el-checkbox-group v-model="form.usageIds">
zs嵩's avatar
zs嵩 committed
66
                    <el-checkbox v-for="item in getDictDatas(DICT_TYPE.WAREHOUSING_RECORD_DETAIL_USAGE)" :key="item.value" :label="item.value">{{ $l(item, "label") }}</el-checkbox>
lanbaoming's avatar
lanbaoming committed
67 68 69 70 71 72 73 74
                  </el-checkbox-group>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>

          <el-card class="box-card">
            <div slot="header" class="clearfix">
zs嵩's avatar
zs嵩 committed
75 76
              <span>{{ $t("入仓记录") }}</span>
              <el-button style="float: right; margin-left: 15px" size="mini" type="primary" icon="el-icon-minus" circle @click="handleDelete" :disabled="form.table.length < protectRowCount"></el-button>
lanbaoming's avatar
lanbaoming committed
77 78 79
              <el-button style="float: right" size="mini" type="primary" icon="el-icon-plus" circle @click="handleAdd()"></el-button>
            </div>
            <el-form ref="tableForm" :rules="tableFormRules" :model="form" size="mini">
zs嵩's avatar
zs嵩 committed
80
              <el-table :data="form.table" style="width: 100%">
lanbaoming's avatar
lanbaoming committed
81
                <el-table-column :label="$t('箱数')" width="150px">
zs嵩's avatar
zs嵩 committed
82 83
                  <template v-slot:header> <span style="color: red">*</span>{{ $t("箱数") }}</template>
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
84 85 86 87 88 89 90 91 92
                    <el-form-item :rules="tableFormRules.cartonsNum">
                      <el-input v-model="form.table[$index].cartonsNum" placeholder="" @blur="handleVolume($index)" :disabled="$index < protectRowCount">
                        <span slot="append">{{ getDictDataLabel(DICT_TYPE.WAREHOUSING_SPECIFICATION_TYPE, form.table[$index].specificationType) }}</span>
                      </el-input>
                      <dict-selector :disabled="$index < protectRowCount" :type="DICT_TYPE.WAREHOUSING_SPECIFICATION_TYPE" v-model="form.table[$index].specificationType" @change="handleVolume($index)"></dict-selector>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column :label="$t('包装类型')" width="100px">
zs嵩's avatar
zs嵩 committed
93 94
                  <template v-slot:header> <span style="color: red">*</span>{{ $t("包装类型") }}</template>
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
95 96 97 98 99 100 101
                    <el-form-item>
                      <dict-selector :disabled="$index < protectRowCount" :type="DICT_TYPE.ECW_PACKAGING_TYPE" v-model="form.table[$index].unit"></dict-selector>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="长(cm)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
102 103
                    <span>{{ $t("") }}</span
                    >(cm)
lanbaoming's avatar
lanbaoming committed
104
                  </template>
zs嵩's avatar
zs嵩 committed
105
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
106 107 108 109 110 111 112
                    <el-form-item :rules="tableFormRules.boxGauge1">
                      <el-input :disabled="$index < protectRowCount" type="number" v-model="form.table[$index].boxGauge1" placeholder="" @blur="handleVolume($index)"></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="宽(cm)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
113 114
                    <span>{{ $t("") }}</span
                    >(cm)
lanbaoming's avatar
lanbaoming committed
115
                  </template>
zs嵩's avatar
zs嵩 committed
116
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
117 118 119 120 121 122 123
                    <el-form-item :rules="tableFormRules.boxGauge2">
                      <el-input :disabled="$index < protectRowCount" type="number" v-model="form.table[$index].boxGauge2" placeholder="" @blur="handleVolume($index)"></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="高(cm)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
124 125
                    <span>{{ $t("") }}</span
                    >(cm)
lanbaoming's avatar
lanbaoming committed
126
                  </template>
zs嵩's avatar
zs嵩 committed
127
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
128 129 130 131 132 133 134
                    <el-form-item :rules="tableFormRules.boxGauge3">
                      <el-input :disabled="$index < protectRowCount" type="number" v-model="form.table[$index].boxGauge3" placeholder="" @blur="handleVolume($index)"></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="体积(m³)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
135 136
                    <span style="color: red">*</span> <span>{{ $t("体积") }}</span
                    >(m³)
lanbaoming's avatar
lanbaoming committed
137
                  </template>
zs嵩's avatar
zs嵩 committed
138
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
139 140 141 142 143 144 145
                    <el-form-item :rules="tableFormRules.volume">
                      <el-input :disabled="$index < protectRowCount" v-model="form.table[$index].volume" placeholder="" type="number"></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="重量(Kg)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
146 147
                    <span style="color: red">*</span> <span>{{ $t("重量") }}</span
                    >(Kg)
lanbaoming's avatar
lanbaoming committed
148
                  </template>
zs嵩's avatar
zs嵩 committed
149
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
150 151 152 153 154 155
                    <el-form-item :rules="tableFormRules.weight">
                      <el-input :disabled="$index < protectRowCount" v-model="form.table[$index].weight" placeholder="" type="number"></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column :label="$t('数量')" width="140px">
zs嵩's avatar
zs嵩 committed
156
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
157 158
                    <el-form-item :rules="tableFormRules.quantityAll">
                      <el-input :disabled="$index < protectRowCount" v-model.number="form.table[$index].quantityAll" placeholder="" type="number">
zs嵩's avatar
zs嵩 committed
159
                        <template slot="append">{{ $t("") }}</template>
lanbaoming's avatar
lanbaoming committed
160 161 162 163 164
                      </el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column :label="$t('快递单号')">
zs嵩's avatar
zs嵩 committed
165
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
166 167 168 169 170
                    <el-form-item>
                      <el-input :disabled="$index < protectRowCount" v-model="form.table[$index].expressNo" placeholder=""></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
zs嵩's avatar
zs嵩 committed
171
                <el-table-column :label="$t('储位')" prop="orderLocationBackVOList" width="150px">
lanbaoming's avatar
lanbaoming committed
172
                  <template v-slot="{ row, column, $index }">
zs嵩's avatar
zs嵩 committed
173
                    <warehouse-area-select v-if="visible" v-model="form.table[$index].orderLocationBackVOList" :order-id="orderId" :order-item-id="warehousing.orderItemId" :warehouse-in-id="form.table[$index].id" :warehouse-id="warehouseId" :is-editing="edit"></warehouse-area-select>
lanbaoming's avatar
lanbaoming committed
174 175 176
                  </template>
                </el-table-column>
                <el-table-column :label="$t('备注')">
zs嵩's avatar
zs嵩 committed
177
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
178 179 180 181 182 183
                    <el-form-item>
                      <el-input v-model="form.table[$index].remark" type="textarea" show-word-limit maxlength="100" placeholder="" :disabled="$index < protectRowCount"></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column :label="$t('操作')">
zs嵩's avatar
zs嵩 committed
184
                  <template v-slot="{ row, column, $index }">
lanbaoming's avatar
lanbaoming committed
185
                    <WarehouseRecordDetail v-model="form.table[$index].orderWarehouseInDetailsVOList" :readonly="$index < protectRowCount" />
zs嵩's avatar
zs嵩 committed
186
                    <el-popconfirm v-if="$index >= protectRowCount" title="确定要删除该行入仓记录吗?" @confirm="handleDeleteRow($index)">
lanbaoming's avatar
lanbaoming committed
187 188 189 190 191 192 193 194 195 196
                      <template v-slot:reference>
                        <el-button size="mini" type="danger">删除</el-button>
                      </template>
                    </el-popconfirm>
                  </template>
                </el-table-column>
              </el-table>
            </el-form>
          </el-card>

zs嵩's avatar
zs嵩 committed
197
          <el-card style="margin-top: 15px">
lanbaoming's avatar
lanbaoming committed
198
            <div slot="header" class="clearfix">
zs嵩's avatar
zs嵩 committed
199
              <span style="font-size: 18px"><span style="color: red">*</span>{{ $t("入仓影像") }}</span>
lanbaoming's avatar
lanbaoming committed
200 201
            </div>
            <div>
zs嵩's avatar
zs嵩 committed
202
              <image-and-video-upload :fileSize="50" :isShowTip="true" v-model="form.pictureUrls" :id="orderItemId" :type="5" @delete="handleImageDelete"></image-and-video-upload>
lanbaoming's avatar
lanbaoming committed
203 204 205 206 207 208 209 210
            </div>
          </el-card>
        </el-tab-pane>

        <el-tab-pane :label="$t('添加新品名')" name="second" v-if="!edit">
          <el-form ref="form1" :model="form1" :rules="formRules" label-width="80px">
            <el-descriptions border :column="2">
              <el-descriptions-item>
zs嵩's avatar
zs嵩 committed
211
                <template slot="label"><span style="color: red">*</span>{{ $t("中文品名") }}</template>
lanbaoming's avatar
lanbaoming committed
212
                <el-form-item required label="" prop="prodId" label-width="0">
zs嵩's avatar
zs嵩 committed
213
                  <product-selector v-model="form1.prodId" @change="onProductChange1" />
lanbaoming's avatar
lanbaoming committed
214 215 216 217
                  <el-button type="text" @click="isShowProduct = true" style="margin-left: 15px">添加新商品</el-button>
                </el-form-item>
              </el-descriptions-item>
              <el-descriptions-item>
zs嵩's avatar
zs嵩 committed
218
                <template slot="label"><span style="color: red">*</span>{{ $t("英文品名") }}</template>
lanbaoming's avatar
lanbaoming committed
219
                <el-form-item required label="" prop="prodId" label-width="0">
zs嵩's avatar
zs嵩 committed
220
                  <product-selector lang="En" v-model="form1.prodId" @change="onProductChange1" />
lanbaoming's avatar
lanbaoming committed
221 222 223
                </el-form-item>
              </el-descriptions-item>
              <el-descriptions-item :label="$t('品牌')">
zs嵩's avatar
zs嵩 committed
224
                <template slot="label"><span style="color: red">*</span>{{ $t("品牌") }}</template>
lanbaoming's avatar
lanbaoming committed
225
                <el-form-item required label="" prop="brand" label-width="0">
zs嵩's avatar
zs嵩 committed
226 227
                  <el-select v-model="form1.brand" :placeholder="$t('可修改')" filterable remote @change="handleBrandChange" :remote-method="getProductBrandPage1" clearable>
                    <el-option v-for="item in brandList1" :key="item.id" :label="item.titleZh" :value="item.id"> </el-option>
lanbaoming's avatar
lanbaoming committed
228 229 230 231
                  </el-select>
                </el-form-item>
              </el-descriptions-item>
              <el-descriptions-item :label="$t('是否备案')">
zs嵩's avatar
zs嵩 committed
232
                <template slot="label"><span style="color: red">*</span>{{ $t("是否备案") }}</template>
lanbaoming's avatar
lanbaoming committed
233 234 235
                {{ isBeian1 }}
              </el-descriptions-item>
              <el-descriptions-item :label="$t('收费模式')">
zs嵩's avatar
zs嵩 committed
236
                <template slot="label"><span style="color: red">*</span>{{ $t("收费模式") }}</template>
lanbaoming's avatar
lanbaoming committed
237 238
                {{ feeType1 }}
              </el-descriptions-item>
zs嵩's avatar
zs嵩 committed
239
              <el-descriptions-item :label="$t('填单参数')">{{ $t("非填单货物") }}</el-descriptions-item>
lanbaoming's avatar
lanbaoming committed
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
            </el-descriptions>
            <el-row>
              <el-col :span="8">
                <el-form-item :label="$t('材质')" style="margin-top: 20px">
                  <dict-selector :type="DICT_TYPE.ECW_PRODUCT_MATERIAL" v-model="form1.material" clearable></dict-selector>
                </el-form-item>
              </el-col>
              <el-col :span="16">
                <el-form-item :label="$t('入仓特性')" style="margin-top: 20px">
                  <el-checkbox-group v-model="form1.warehouseInProdAttrIds">
                    <el-checkbox v-for="item in attrList" :key="item.id" :label="item.id">{{ item.attrName }}</el-checkbox>
                  </el-checkbox-group>
                </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item :label="$t('入仓时间')">
                  <el-date-picker v-model="form1.inTime" type="datetime" :placeholder="$t('请选择入仓时间')" value-format="yyyy-MM-dd HH:mm:ss"></el-date-picker>
                </el-form-item>
              </el-col>

              <el-col :span="16">
                <el-form-item :label="$t('用途')">
                  <el-checkbox-group v-model="form1.usageIds">
zs嵩's avatar
zs嵩 committed
263
                    <el-checkbox v-for="item in getDictDatas(DICT_TYPE.WAREHOUSING_RECORD_DETAIL_USAGE)" :key="item.value" :label="item.value">{{ $l(item, "label") }}</el-checkbox>
lanbaoming's avatar
lanbaoming committed
264 265 266 267 268 269 270 271
                  </el-checkbox-group>
                </el-form-item>
              </el-col>
            </el-row>
          </el-form>

          <el-card class="box-card">
            <div slot="header" class="clearfix">
zs嵩's avatar
zs嵩 committed
272 273
              <span>{{ $t("入仓记录") }}</span>
              <el-button style="float: right; margin-left: 15px" size="mini" type="primary" icon="el-icon-minus" circle @click="handleDelete(1)"></el-button>
lanbaoming's avatar
lanbaoming committed
274 275 276
              <el-button style="float: right" size="mini" type="primary" icon="el-icon-plus" circle @click="handleAdd(1)"></el-button>
            </div>
            <el-form ref="tableForm1" :model="form1" :rules="tableFormRules" size="mini">
zs嵩's avatar
zs嵩 committed
277
              <el-table :data="form1.table" style="width: 100%">
lanbaoming's avatar
lanbaoming committed
278
                <el-table-column :label="$t('箱数')" width="150px">
zs嵩's avatar
zs嵩 committed
279 280
                  <template v-slot:header> <span style="color: red">*</span>{{ $t("箱数") }}</template>
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
281 282 283 284 285 286 287 288 289 290 291 292 293
                    <el-form-item>
                      <span v-if="form1.table[$index].id">
                        {{ form1.table[$index].cartonsNum }}
                        {{ getDictDataLabel(DICT_TYPE.ECW_PACKAGING_TYPE, form1.table[$index].unit) }}
                      </span>
                      <el-input v-else v-model="form1.table[$index].cartonsNum" placeholder="" @blur="handleVolume($index, 1)">
                        <span slot="append">{{ getDictDataLabel(DICT_TYPE.ECW_PACKAGING_TYPE, form1.table[$index].unit) }}</span>
                      </el-input>
                      <dict-selector :type="DICT_TYPE.WAREHOUSING_SPECIFICATION_TYPE" v-model="form1.table[$index].specificationType" @change="handleVolume($index, 1)"></dict-selector>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column :label="$t('包装类型')" width="100px">
zs嵩's avatar
zs嵩 committed
294 295
                  <template v-slot:header> <span style="color: red">*</span>{{ $t("包装类型") }}</template>
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
296 297 298 299 300 301 302 303
                    <el-form-item>
                      <span v-if="form1.table[$index].id">{{ getDictDataLabel(DICT_TYPE.ECW_PACKAGING_TYPE, form1.table[$index].unit) }}</span>
                      <dict-selector v-else :type="DICT_TYPE.ECW_PACKAGING_TYPE" v-model="form1.table[$index].unit"></dict-selector>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="长(cm)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
304 305
                    <span>{{ $t("") }}</span
                    >(cm)
lanbaoming's avatar
lanbaoming committed
306
                  </template>
zs嵩's avatar
zs嵩 committed
307
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
308
                    <el-form-item>
zs嵩's avatar
zs嵩 committed
309
                      <span v-if="form1.table[$index].id">{{ form1.table[$index].boxGauge ? form1.table[$index].boxGauge.split("*")[0] : "" }}</span>
lanbaoming's avatar
lanbaoming committed
310 311 312 313 314 315
                      <el-input v-else type="number" v-model="form1.table[$index].boxGauge1" placeholder="" @blur="handleVolume($index, 1)"></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="宽(cm)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
316 317
                    <span>{{ $t("") }}</span
                    >(cm)
lanbaoming's avatar
lanbaoming committed
318
                  </template>
zs嵩's avatar
zs嵩 committed
319
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
320
                    <el-form-item>
zs嵩's avatar
zs嵩 committed
321
                      <span v-if="form1.table[$index].id">{{ form1.table[$index].boxGauge ? form1.table[$index].boxGauge.split("*")[1] : "" }}</span>
lanbaoming's avatar
lanbaoming committed
322 323 324 325 326 327
                      <el-input v-else type="number" v-model="form1.table[$index].boxGauge2" placeholder="" @blur="handleVolume($index, 1)"></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="高(cm)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
328 329
                    <span>{{ $t("") }}</span
                    >(cm)
lanbaoming's avatar
lanbaoming committed
330
                  </template>
zs嵩's avatar
zs嵩 committed
331
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
332
                    <el-form-item>
zs嵩's avatar
zs嵩 committed
333
                      <span v-if="form1.table[$index].id">{{ form1.table[$index].boxGauge ? form1.table[$index].boxGauge.split("*")[2] : "" }}</span>
lanbaoming's avatar
lanbaoming committed
334 335 336 337 338 339
                      <el-input v-else type="number" v-model="form1.table[$index].boxGauge3" placeholder="" @blur="handleVolume($index, 1)"></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="体积(m³)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
340 341
                    <span style="color: red">*</span> <span>{{ $t("体积") }}</span
                    >(m³)
lanbaoming's avatar
lanbaoming committed
342
                  </template>
zs嵩's avatar
zs嵩 committed
343
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
344 345 346 347 348 349 350 351
                    <el-form-item>
                      <span v-if="form1.table[$index].id">{{ form1.table[$index].volume }}</span>
                      <el-input v-else type="number" v-model="form1.table[$index].volume" placeholder=""></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column label="重量(Kg)">
                  <template v-slot:header>
zs嵩's avatar
zs嵩 committed
352 353
                    <span style="color: red">*</span> <span>{{ $t("重量") }}</span
                    >(Kg)
lanbaoming's avatar
lanbaoming committed
354
                  </template>
zs嵩's avatar
zs嵩 committed
355
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
356 357 358 359 360 361 362
                    <el-form-item>
                      <span v-if="form1.table[$index].id">{{ form1.table[$index].weight }}</span>
                      <el-input v-else type="number" v-model="form1.table[$index].weight" placeholder=""></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column :label="$t('数量')" width="140px">
zs嵩's avatar
zs嵩 committed
363
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
364 365 366
                    <el-form-item>
                      <span v-if="form1.table[$index].id">{{ form1.table[$index].quantityAll }}</span>
                      <el-input v-else type="number" v-model.number="form1.table[$index].quantityAll" placeholder="">
zs嵩's avatar
zs嵩 committed
367
                        <template slot="append">{{ $t("") }}</template>
lanbaoming's avatar
lanbaoming committed
368 369 370 371 372
                      </el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
                <el-table-column :label="$t('快递单号')">
zs嵩's avatar
zs嵩 committed
373
                  <template v-slot="{ r, c, $index }">
lanbaoming's avatar
lanbaoming committed
374 375 376 377 378 379
                    <el-form-item>
                      <span v-if="form1.table[$index].id">{{ form1.table[$index].expressNo }}</span>
                      <el-input v-else v-model="form1.table[$index].expressNo" placeholder=""></el-input>
                    </el-form-item>
                  </template>
                </el-table-column>
zs嵩's avatar
zs嵩 committed
380
                <el-table-column :label="$t('储位')" prop="orderLocationBackVOList" width="150px">
lanbaoming's avatar
lanbaoming committed
381
                  <template v-slot="{ row, column, $index }">
zs嵩's avatar
zs嵩 committed
382
                    <warehouse-area-select v-model="form1.table[$index].orderLocationBackVOList" :readonly="form1.table[$index].id && !edit" :order-id="orderId" :order-item-id="warehousing.orderItemId" :warehouse-in-id="form1.table[$index].id" :warehouse-id="warehouseId" :is-editing="edit"></warehouse-area-select>
lanbaoming's avatar
lanbaoming committed
383 384 385
                  </template>
                </el-table-column>
                <el-table-column :label="$t('操作')">
zs嵩's avatar
zs嵩 committed
386
                  <template v-slot="{ row, column, $index }">
lanbaoming's avatar
lanbaoming committed
387
                    <WarehouseRecordDetail v-model="form1.table[$index].orderWarehouseInDetailsVOList" />
zs嵩's avatar
zs嵩 committed
388
                    <el-popconfirm title="确定要删除该行入仓记录吗?" @confirm="handleDeleteRow($index, 1)">
lanbaoming's avatar
lanbaoming committed
389 390 391 392 393 394 395 396 397 398
                      <template v-slot:reference>
                        <el-button size="mini" type="danger">删除</el-button>
                      </template>
                    </el-popconfirm>
                  </template>
                </el-table-column>
              </el-table>
            </el-form>
          </el-card>

zs嵩's avatar
zs嵩 committed
399
          <el-card style="margin-top: 15px">
lanbaoming's avatar
lanbaoming committed
400
            <div slot="header" class="clearfix">
zs嵩's avatar
zs嵩 committed
401
              <span style="font-size: 18px"><span style="color: red">*</span>{{ $t("入仓影像") }}</span>
lanbaoming's avatar
lanbaoming committed
402 403
            </div>
            <div>
zs嵩's avatar
zs嵩 committed
404
              <image-and-video-upload :fileSize="50" :isShowTip="true" v-model="form1.pictureUrls"></image-and-video-upload>
lanbaoming's avatar
lanbaoming committed
405 406 407 408 409
            </div>
          </el-card>
        </el-tab-pane>
      </el-tabs>

410
      <div v-if="(edit && order.status !== 3) || isShipment">
lanbaoming's avatar
lanbaoming committed
411 412 413 414 415 416 417
        <h2>{{ $t('审批流程') }}</h2>
        <work-flow xmlkey="free_apply" v-model="selectedUsers"  />
        <!--        <div>选择的用户:{{selectedUsers}}</div>-->
      </div>

      <span slot="footer">
        <template v-if="!isEditing">
zs嵩's avatar
zs嵩 committed
418 419
          <el-button @click="handleClose">{{ $t("关 闭") }}</el-button>
          <el-button type="primary" :loading="submitting" @click="handleSubmit()">{{ edit ? $t("确认修改") : $t("提 交") }}</el-button>
lanbaoming's avatar
lanbaoming committed
420 421
        </template>
        <template v-else>
zs嵩's avatar
zs嵩 committed
422 423 424
          <el-button type="primary" @click="$router.push('/bpm/process-instance/detail?id=' + formId)">{{ $t("审核中") }}</el-button>
          <el-button type="primary" @click="handleCancelProcessInstance">{{ $t("取消审核") }}</el-button>
          <el-button @click="handleClose">{{ $t("返回") }}</el-button>
lanbaoming's avatar
lanbaoming committed
425
        </template>
zs嵩's avatar
zs嵩 committed
426
        <template v-else> </template>
lanbaoming's avatar
lanbaoming committed
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
      </span>
    </el-dialog>

    <!-- 对话框(添加 / 修改) -->
    <el-dialog title="添加商品" :visible.sync="isShowProduct" width="550px" append-to-body>
      <el-form ref="productForm" :model="productForm" :rules="productRules" label-width="110px">
        <el-form-item :label="$t('商品类型')" prop="typeId">
          <el-select v-model="productForm.typeId" :placeholder="$t('选择商品类型')" clearable>
            <el-option v-for="types in typeList" :key="types.id" :label="types.titleZh" :value="types.id" />
          </el-select>
        </el-form-item>

        <el-form-item :label="$t('中文标题')" prop="titleZh">
          <el-input v-model="productForm.titleZh" :placeholder="$t('请输入中文标题')" />
        </el-form-item>

        <el-form-item :label="$t('英文标题')" prop="titleEn">
          <el-input v-model="productForm.titleEn" :placeholder="$t('请输入英文标题')" />
        </el-form-item>

        <el-form-item :label="$t('商品特性')" prop="attrArray">
          <el-select v-model="productForm.attrArray" :placeholder="$t('选择商品特性')" clearable multiple>
            <el-option v-for="attr in attrList" :key="attr.id" :label="attr.attrName" :value="attr.id" />
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
zs嵩's avatar
zs嵩 committed
454 455
        <el-button type="primary" @click="productSubmit">{{ $t("确定") }}</el-button>
        <el-button @click="productCancel">{{ $t("取消") }}</el-button>
lanbaoming's avatar
lanbaoming committed
456 457 458 459 460 461 462 463
      </div>
    </el-dialog>
  </div>
</template>

<script>
import ProductSelector from "@/components/ProductSelector"
import WarehouseAreaSelect from "@/components/WarehouseAreaSelect"
zs嵩's avatar
zs嵩 committed
464 465
import { getFeeTypeByOrderProduct, getProductBrankPage } from "@/api/ecw/productBrank"
import { cancelProcessInstance } from "@/api/bpm/processInstance"
lanbaoming's avatar
lanbaoming committed
466
import WorkFlow from "@/components/WorkFlow"
zs嵩's avatar
zs嵩 committed
467 468 469 470 471
import { DICT_TYPE, getDictDataLabel, getDictDatas } from "@/utils/dict"
import { orderWarehouseIn, orderWarehouseInUpdateApply, warehousePictureDelete, warehousePictureList } from "@/api/ecw/order"
import { getProductAttrList } from "@/api/ecw/productAttr"
import { getProductTypeList } from "@/api/ecw/productType"
import { addProduct } from "@/api/ecw/product"
lanbaoming's avatar
lanbaoming committed
472 473
import ImageAndVideoUpload from "@/components/ImageAndVideoUpload/index.vue"
import WarehouseRecordDetail from "@/views/ecw/order/warehousing/components/WarehouseRecordDetail.vue"
474
import { appendApplyWhenShipment, updateApplyWhenShipment } from '@/api/ecw/warehouse'
lanbaoming's avatar
lanbaoming committed
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523

export default {
  name: "Warehouse",

  components: {
    WarehouseRecordDetail,
    ImageAndVideoUpload,
    ProductSelector,
    WarehouseAreaSelect,
    WorkFlow
  },

  props: {
    title: {
      type: String,
      default: undefined
    },
    order: {
      type: Object,
      default: undefined
    },
    isJiyun: {
      type: Boolean,
      default: false
    },
    // 入仓修改
    edit: {
      type: Boolean,
      default: false
    },
    orderItemA: {
      type: Object,
      default: () => {
        return {
          material: undefined,
          inTime: undefined,
          orderWarehouseInBackItemDoList: []
        }
      }
    },
    orderItemB: {
      type: Object,
      default: () => {
        return {
          material: undefined,
          inTime: undefined,
          orderWarehouseInBackItemDoList: []
        }
      }
524 525 526 527
    },
    isShipment:{
      type: Boolean,
      default: false
lanbaoming's avatar
lanbaoming committed
528 529 530 531 532 533 534 535 536 537 538 539
    }
  },

  mounted() {
    this.getAttrList()
    this.getTypeList()
  },

  computed: {
    isAdd() {
      return this.$route.path === "/order/warehousing-add"
    },
zs嵩's avatar
zs嵩 committed
540 541
    warehousing() {
      return { ...this.orderItemA, ...this.orderItemB }
lanbaoming's avatar
lanbaoming committed
542
    },
zs嵩's avatar
zs嵩 committed
543
    orderId() {
lanbaoming's avatar
lanbaoming committed
544 545
      return this.order.orderId
    },
zs嵩's avatar
zs嵩 committed
546
    orderItemId() {
lanbaoming's avatar
lanbaoming committed
547 548
      return this.warehousing.orderItemId
    },
zs嵩's avatar
zs嵩 committed
549 550
    brandObject() {
      return this.brandList.find((e) => e.id === this.form.brand) || ""
lanbaoming's avatar
lanbaoming committed
551
    },
zs嵩's avatar
zs嵩 committed
552 553
    brandObject1() {
      return this.brandList.find((e) => e.id === this.form1.brand) || ""
lanbaoming's avatar
lanbaoming committed
554
    },
zs嵩's avatar
zs嵩 committed
555 556 557
    isBeian() {
      if (this.form.recordMode !== undefined) {
        return [this.$t("无备案"), this.$t("有备案"), this.$t("中性")][this.form.recordMode]
lanbaoming's avatar
lanbaoming committed
558
      }
zs嵩's avatar
zs嵩 committed
559 560
      if (this.brandObject.filing) {
        return [this.$t("无备案"), this.$t("有备案"), this.$t("中性")][this.brandObject.filing]
lanbaoming's avatar
lanbaoming committed
561
      } else {
zs嵩's avatar
zs嵩 committed
562
        return ""
lanbaoming's avatar
lanbaoming committed
563 564
      }
    },
zs嵩's avatar
zs嵩 committed
565 566 567
    isBeian1() {
      if (this.form1.recordMode !== undefined) {
        return [this.$t("无备案"), this.$t("有备案"), this.$t("中性")][this.form1.recordMode]
lanbaoming's avatar
lanbaoming committed
568
      }
zs嵩's avatar
zs嵩 committed
569 570
      if (this.brandObject1.filing) {
        return [this.$t("无备案"), this.$t("有备案"), this.$t("中性")][this.brandObject1.filing]
lanbaoming's avatar
lanbaoming committed
571
      } else {
zs嵩's avatar
zs嵩 committed
572
        return ""
lanbaoming's avatar
lanbaoming committed
573 574 575 576 577 578
      }
    },
    /**
     * 收费模式
     * @returns {string} 无牌价0,有牌价1,中性品牌价2
     */
zs嵩's avatar
zs嵩 committed
579
    feeType() {
lanbaoming's avatar
lanbaoming committed
580 581
      const feeType = this.form.feeType
      if (feeType >= 0 && feeType < 3) {
zs嵩's avatar
zs嵩 committed
582
        return [this.$t("无牌价"), this.$t("有牌价"), this.$t("中性品牌价")][feeType]
lanbaoming's avatar
lanbaoming committed
583
      }
zs嵩's avatar
zs嵩 committed
584
      return ""
lanbaoming's avatar
lanbaoming committed
585
    },
zs嵩's avatar
zs嵩 committed
586
    feeType1() {
lanbaoming's avatar
lanbaoming committed
587 588
      const feeType = parseInt(this.form1.feeType)
      if (feeType >= 0 && feeType < 3) {
zs嵩's avatar
zs嵩 committed
589
        return [this.$t("无牌价"), this.$t("有牌价"), this.$t("中性品牌价")][feeType]
lanbaoming's avatar
lanbaoming committed
590
      }
zs嵩's avatar
zs嵩 committed
591
      return ""
lanbaoming's avatar
lanbaoming committed
592
    },
zs嵩's avatar
zs嵩 committed
593
    warehouseId() {
lanbaoming's avatar
lanbaoming committed
594 595 596 597 598
      return this.order.adjustToDestWarehouseId || this.order?.logisticsInfoDto?.startWarehouseId
    }
  },

  watch: {
zs嵩's avatar
zs嵩 committed
599
    visible(val) {
lanbaoming's avatar
lanbaoming committed
600 601 602 603 604 605
      if (val) {
        this.init()
        this.getProductBrandPage(this.warehousing.brandName)
        this.getProductBrandPage1()
        this.handleBrandChange(parseInt(this.form.brand))
      } else {
zs嵩's avatar
zs嵩 committed
606
        this.$emit("close")
lanbaoming's avatar
lanbaoming committed
607 608 609 610
      }
    }
  },

zs嵩's avatar
zs嵩 committed
611
  data() {
lanbaoming's avatar
lanbaoming committed
612 613 614 615
    return {
      DICT_TYPE,
      getDictDataLabel,
      getDictDatas,
zs嵩's avatar
zs嵩 committed
616
      activeName: "first",
lanbaoming's avatar
lanbaoming committed
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
      visible: false,
      submitting: false,
      form: {
        table: [],
        brandType: undefined,
        orderId: undefined,
        orderNo: undefined,
        brand: undefined,
        inTime: undefined,
        material: undefined,
        orderItemId: undefined,
        warehouseInProdAttrIds: [],
        prodId: undefined,
        prodTitleEn: undefined,
        prodTitleZh: undefined,
        prodType: undefined,
        type: undefined,
        feeType: undefined,
        recordMode: undefined,
        pictureUrls: [],
        usageIds: []
      },
      form1: {
        table: [],
        brandType: undefined,
        orderId: undefined,
        orderNo: undefined,
        brand: undefined,
        inTime: undefined,
        material: undefined,
        orderItemId: undefined,
        warehouseInProdAttrIds: [],
        prodId: undefined,
        prodTitleEn: undefined,
        prodTitleZh: undefined,
        prodType: undefined,
        type: 1,
        feeType: undefined,
        recordMode: undefined,
        pictureUrls: [],
        usageIds: []
      },
      brandList: [],
      brandList1: [],
      formRules: {
zs嵩's avatar
zs嵩 committed
662 663
        prodId: [{ required: true, message: this.$t("请选择品名"), trigger: "change" }],
        brand: [{ required: true, message: this.$t("请选择品牌"), trigger: "change" }]
lanbaoming's avatar
lanbaoming committed
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
      },
      tableFormRules: {
        // cartonsNum: [{required: true, message: this.$t("箱数不能为空"), trigger: "change"}],
        // boxGauge1: [{required: true, message: this.$t("货物长不能为空"), trigger: "change"}],
        // boxGauge2: [{required: true, message: this.$t("货物宽不能为空"), trigger: "change"}],
        // boxGauge3: [{required: true, message: this.$t("货物高不能为空"), trigger: "change"}],
        // volume: [{required: true, message: this.$t("体积不能为空"), trigger: "change"}],
        // weight: [{required: true, message: this.$t("重量不能为空"), trigger: "change"}],
        // // quantityAll: [{required: true, message: this.$t("数量不能为空"), trigger: "change"}]
      },

      selectedUsers: undefined,

      // 入仓修改正在审核中
      isEditing: false,
      // 审批业务id
zs嵩's avatar
zs嵩 committed
680
      formId: "",
lanbaoming's avatar
lanbaoming committed
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696

      // 追加时被保护的行数
      protectRowCount: -1,

      // 添加商品弹窗
      isShowProduct: false,
      productForm: {
        typeId: undefined,
        attrArray: [],
        titleZh: undefined,
        titleEn: undefined
      },
      productRules: {
        typeId: [{ required: true, message: this.$t("商品类型不能为空"), trigger: "change" }],
        // attrArray: [{ required: true, message: this.$t("商品特性不能为空"), trigger: "change" }],
        titleZh: [{ required: true, message: this.$t("中文标题不能为空"), trigger: "blur" }],
zs嵩's avatar
zs嵩 committed
697
        titleEn: [{ required: true, message: this.$t("英文标题不能为空"), trigger: "blur" }]
lanbaoming's avatar
lanbaoming committed
698 699 700 701 702 703 704 705 706
      },
      //类型列表
      typeList: [],
      // 特性列表
      attrList: []
    }
  },

  methods: {
zs嵩's avatar
zs嵩 committed
707
    init() {
lanbaoming's avatar
lanbaoming committed
708 709 710 711 712 713 714 715 716 717 718
      this.form.brandType = this.warehousing.brandType
      this.form.orderId = this.warehousing.orderId
      this.form.orderItemId = this.warehousing.orderNo
      this.form.orderNo = this.warehousing.orderNo
      this.form.brand = this.warehousing.brand
      this.form.brandType = this.warehousing.brandType
      this.form.inTime = this.warehousing.inTime
      this.form.material = this.warehousing.material
      this.form.orderId = this.warehousing.orderId
      this.form.orderItemId = this.warehousing.orderItemId
      this.form.orderNo = this.warehousing.orderNo
zs嵩's avatar
zs嵩 committed
719 720
      if ((this.edit || this.isAdd) && this.warehousing.warehouseInProdAttrIds !== null) {
        this.form.warehouseInProdAttrIds = this.warehousing.warehouseInProdAttrIds?.split(",").map((e) => +e) || []
lanbaoming's avatar
lanbaoming committed
721
      } else {
zs嵩's avatar
zs嵩 committed
722
        this.form.warehouseInProdAttrIds = this.warehousing.warehouseInProdAttrIds?.split(",").map((e) => +e) || this.warehousing.prodAttrIds?.split(",").map((e) => +e) || []
lanbaoming's avatar
lanbaoming committed
723 724 725 726 727 728 729 730
      }
      this.form.prodId = this.warehousing.prodId
      this.form.prodTitleEn = this.warehousing.prodTitleEn
      this.form.prodTitleZh = this.warehousing.prodTitleZh
      this.form.prodType = this.warehousing.prodType
      this.form.type = this.warehousing.type
      this.form.feeType = this.warehousing.feeType
      this.form.pictureUrls = this.warehousing.pictureUrls
zs嵩's avatar
zs嵩 committed
731 732
      this.form.usageIds = this.warehousing.usageIds ? this.warehousing.usageIds.split(",") : []
      if (this.form.usageIds.length > 0 && this.form.usageIds[0] === "") {
lanbaoming's avatar
lanbaoming committed
733 734
        this.usageIds.splice(0, 1)
      }
zs嵩's avatar
zs嵩 committed
735
      this.warehousing.orderWarehouseInBackItemDoList.forEach((e) => {
lanbaoming's avatar
lanbaoming committed
736 737
        let bg = {}
        if (e.boxGauge) {
zs嵩's avatar
zs嵩 committed
738
          const boxGauge = e.boxGauge.split("*")
lanbaoming's avatar
lanbaoming committed
739 740 741 742 743 744 745 746 747
          // e.boxGauge1 = boxGauge[0]
          // e.boxGauge2 = boxGauge[1]
          // e.boxGauge3 = boxGauge[2]
          bg = {
            boxGauge1: boxGauge[0],
            boxGauge2: boxGauge[1],
            boxGauge3: boxGauge[2]
          }
        }
zs嵩's avatar
zs嵩 committed
748
        this.form.table.push({ ...e, ...bg })
lanbaoming's avatar
lanbaoming committed
749 750
      })

zs嵩's avatar
zs嵩 committed
751
      if (!this.edit) {
lanbaoming's avatar
lanbaoming committed
752
        let protectRowCount = 0
zs嵩's avatar
zs嵩 committed
753 754
        this.protectRowCount = this.form.table.map((e) => {
          if (e.id) {
lanbaoming's avatar
lanbaoming committed
755 756 757 758 759 760 761 762 763 764 765 766
            protectRowCount++
          }
        })
        this.protectRowCount = protectRowCount
        this.handleAdd()
        this.handleAdd(1)
      }
    },
    handleImageDelete(url) {
      warehousePictureList({
        bizId: this.orderId,
        type: 1
zs嵩's avatar
zs嵩 committed
767
      }).then((r) => {
lanbaoming's avatar
lanbaoming committed
768 769
        console.log(r, url)
        if (r.data?.length > 0) {
zs嵩's avatar
zs嵩 committed
770
          const id = r.data.find((e) => e?.url === url)?.id
lanbaoming's avatar
lanbaoming committed
771
          if (id) {
zs嵩's avatar
zs嵩 committed
772
            warehousePictureDelete(id).then((r) => {
lanbaoming's avatar
lanbaoming committed
773 774 775 776 777 778 779 780 781
              console.log(r)
            })
          }
        }
      })
    },
    handleClose() {
      this.visible = false
    },
zs嵩's avatar
zs嵩 committed
782
    handleVolume(index, val) {
lanbaoming's avatar
lanbaoming committed
783
      setTimeout(() => {
zs嵩's avatar
zs嵩 committed
784 785
        const { boxGauge1, boxGauge2, boxGauge3, specificationType, cartonsNum } = (val === 1 ? this.form1.table : this.form.table)[index]
        let result = ""
lanbaoming's avatar
lanbaoming committed
786
        if (boxGauge1 && boxGauge2 && boxGauge3 && specificationType && cartonsNum) {
zs嵩's avatar
zs嵩 committed
787
          result = (((specificationType === 1 || specificationType === "1" ? cartonsNum : 1) * (boxGauge1 * boxGauge2 * boxGauge3)) / 1000000 + 0.000001)?.toFixed(2) || ""
lanbaoming's avatar
lanbaoming committed
788
        } else {
zs嵩's avatar
zs嵩 committed
789
          result = ""
lanbaoming's avatar
lanbaoming committed
790
        }
zs嵩's avatar
zs嵩 committed
791 792
        if (result === "0.00") result = "0.01"
        ;(val === 1 ? this.form1.table : this.form.table)[index].volume = result
lanbaoming's avatar
lanbaoming committed
793 794 795
      }, 0)
    },
    handleSubmit() {
zs嵩's avatar
zs嵩 committed
796
      if (this.activeName !== "first") {
lanbaoming's avatar
lanbaoming committed
797 798 799
        // 添加非填单货物
        if (this.form1.warehouseInProdAttrIds.indexOf(4) !== -1) {
          return this.$notify({
zs嵩's avatar
zs嵩 committed
800
            title: this.$t("提示"),
lanbaoming's avatar
lanbaoming committed
801
            message: this.$t("订单包含不接受货物,请检查"),
zs嵩's avatar
zs嵩 committed
802
            type: "warning"
lanbaoming's avatar
lanbaoming committed
803 804
          })
        }
zs嵩's avatar
zs嵩 committed
805 806
        this.$refs["form1"].validate((valid) => {
          this.$refs["tableForm1"].validate((valid1) => {
lanbaoming's avatar
lanbaoming committed
807 808 809 810
            if (!valid || !valid1) {
              return
            }
            this.submitting = true
811
            const func = this.isShipment ? appendApplyWhenShipment : orderWarehouseIn
812
            console.log("提交追加", this.isShipment, func)
813
            return func({
lanbaoming's avatar
lanbaoming committed
814 815 816 817 818
              ...this.form1,
              brandType: this.warehousing.brandType,
              orderId: this.warehousing.orderId,
              orderItemId: undefined,
              orderNo: this.warehousing.orderNo,
zs嵩's avatar
zs嵩 committed
819 820 821
              warehouseInProdAttrIds: this.form1.warehouseInProdAttrIds.join(","),
              usageIds: this.form1.usageIds.join(","),
              orderWarehouseInItemDoList: this.form1.table.map((e) => {
lanbaoming's avatar
lanbaoming committed
822 823
                return {
                  ...e,
zs嵩's avatar
zs嵩 committed
824
                  boxGauge: e.boxGauge1 + "*" + e.boxGauge2 + "*" + e.boxGauge3,
lanbaoming's avatar
lanbaoming committed
825 826 827 828
                  orderLocationCreateReqVOList: e.orderLocationBackVOList
                }
              })
            })
zs嵩's avatar
zs嵩 committed
829 830 831 832 833 834 835 836 837 838 839 840
              .then((r) => {
                this.submitting = false
                if (r.data) {
                  this.$message.success("新增入仓成功")
                  this.handleClose()
                } else {
                  this.$message.success("新增入仓失败")
                }
              })
              .catch(() => {
                this.submitting = false
              })
lanbaoming's avatar
lanbaoming committed
841 842 843 844 845
          })
        })
      } else {
        if (this.form.warehouseInProdAttrIds.indexOf(4) !== -1) {
          return this.$notify({
zs嵩's avatar
zs嵩 committed
846
            title: this.$t("提示"),
lanbaoming's avatar
lanbaoming committed
847
            message: this.$t("订单包含不接受货物,请检查"),
zs嵩's avatar
zs嵩 committed
848
            type: "warning"
lanbaoming's avatar
lanbaoming committed
849 850
          })
        }
zs嵩's avatar
zs嵩 committed
851 852
        this.$refs["form"].validate((valid) => {
          this.$refs["tableForm"].validate((valid1) => {
lanbaoming's avatar
lanbaoming committed
853 854 855 856 857 858
            if (!valid || !valid1) {
              return
            }
            if (this.edit) {
              // 入仓修改
              this.submitting = true
859 860
              const func = this.isShipment ? updateApplyWhenShipment : orderWarehouseInUpdateApply
              return func({
lanbaoming's avatar
lanbaoming committed
861 862 863 864 865 866
                ...this.form,
                brandType: this.warehousing.brandType,
                orderId: this.warehousing.orderId,
                orderItemId: this.warehousing.orderItemId,
                orderNo: this.warehousing.orderNo,
                num: this.warehousing.num,
zs嵩's avatar
zs嵩 committed
867 868
                volume: (+this.warehousing.volume)?.toFixed(2) || "",
                weight: (+this.warehousing.weight)?.toFixed(2) || "",
lanbaoming's avatar
lanbaoming committed
869
                prodId: this.form.prodId,
zs嵩's avatar
zs嵩 committed
870 871 872
                warehouseInProdAttrIds: this.form.warehouseInProdAttrIds.join(","),
                usageIds: this.form.usageIds.join(","),
                orderWarehouseInUpdateItemDoList: this.form.table.map((e) => {
lanbaoming's avatar
lanbaoming committed
873 874
                  return {
                    ...e,
zs嵩's avatar
zs嵩 committed
875
                    boxGauge: e.boxGauge1 + "*" + e.boxGauge2 + "*" + e.boxGauge3,
lanbaoming's avatar
lanbaoming committed
876 877 878 879 880
                    orderLocationCreateReqVOList: e.orderLocationBackVOList
                  }
                }),
                copyUserId: this.selectedUsers
              })
zs嵩's avatar
zs嵩 committed
881 882 883
                .then((r) => {
                  this.submitting = false
                  if (r.data) {
884
                    this.$message.success(this.$t("入仓修改发起成功"))
zs嵩's avatar
zs嵩 committed
885 886 887 888 889 890 891 892
                    this.handleClose()
                  } else {
                    this.$message.success(r.msg || "入仓修改发起失败")
                  }
                })
                .catch(() => {
                  this.submitting = false
                })
lanbaoming's avatar
lanbaoming committed
893 894 895
            } else {
              // 首次入仓、入仓补充
              this.submitting = true
896 897
              const func = this.isShipment ? appendApplyWhenShipment : orderWarehouseIn
              return func({
lanbaoming's avatar
lanbaoming committed
898 899 900 901 902 903
                ...this.form,
                brandType: this.warehousing.brandType,
                orderId: this.warehousing.orderId,
                orderItemId: this.warehousing.orderItemId,
                orderNo: this.warehousing.orderNo,
                isAppend: this.isAdd ? true : undefined,
zs嵩's avatar
zs嵩 committed
904 905 906
                warehouseInProdAttrIds: this.form.warehouseInProdAttrIds.join(","),
                usageIds: this.form.usageIds.join(","),
                orderWarehouseInItemDoList: this.form.table.map((e) => {
lanbaoming's avatar
lanbaoming committed
907 908
                  return {
                    ...e,
zs嵩's avatar
zs嵩 committed
909
                    boxGauge: e.boxGauge1 + "*" + e.boxGauge2 + "*" + e.boxGauge3,
lanbaoming's avatar
lanbaoming committed
910 911
                    orderLocationCreateReqVOList: e.orderLocationBackVOList
                  }
zs嵩's avatar
zs嵩 committed
912
                })
lanbaoming's avatar
lanbaoming committed
913
              })
zs嵩's avatar
zs嵩 committed
914 915 916
                .then((r) => {
                  this.submitting = false
                  if (r.data) {
917
                    this.$message.success(this.isShipment ? this.$t('入仓追加已提交审批') : this.$t("入仓成功"))
zs嵩's avatar
zs嵩 committed
918 919 920 921 922 923 924 925
                    this.handleClose()
                  } else {
                    this.$message.success("入仓失败")
                  }
                })
                .catch(() => {
                  this.submitting = false
                })
lanbaoming's avatar
lanbaoming committed
926 927 928 929 930
            }
          })
        })
      }
    },
zs嵩's avatar
zs嵩 committed
931 932 933
    handleCancelProcessInstance() {
      this.$prompt("请输入取消原因?", this.$t("取消流程"), {
        type: "warning",
lanbaoming's avatar
lanbaoming committed
934 935 936
        confirmButtonText: this.$t("确定"),
        cancelButtonText: this.$t("取消"),
        inputPattern: /^[\s\S]*.*\S[\s\S]*$/, // 判断非空,且非空格
zs嵩's avatar
zs嵩 committed
937
        inputErrorMessage: this.$t("取消原因不能为空")
lanbaoming's avatar
lanbaoming committed
938 939 940
      }).then(({ value }) => {
        cancelProcessInstance(this.formId, value).then(() => {
          this.opened = false
zs嵩's avatar
zs嵩 committed
941
          this.$modal.msgSuccess("取消成功")
lanbaoming's avatar
lanbaoming committed
942 943 944
        })
      })
    },
zs嵩's avatar
zs嵩 committed
945
    onProductChange(product) {
lanbaoming's avatar
lanbaoming committed
946 947 948 949 950 951
      if (!product) {
        return
      }
      this.form.prodTitleZh = product.titleZh
      this.form.prodTitleEn = product.titleEn
      this.handleBrandChange(parseInt(this.form.brand))
zs嵩's avatar
zs嵩 committed
952
      this.form.warehouseInProdAttrIds = product.attrId ? product.attrId.split(",").map((e) => +e) : []
lanbaoming's avatar
lanbaoming committed
953
    },
zs嵩's avatar
zs嵩 committed
954
    onProductChange1(product) {
lanbaoming's avatar
lanbaoming committed
955 956 957 958 959 960
      if (!product) {
        return
      }
      this.form1.prodTitleZh = product.titleZh
      this.form1.prodTitleEn = product.titleEn
      this.handleBrandChange(parseInt(this.form1.brand))
zs嵩's avatar
zs嵩 committed
961
      this.form1.warehouseInProdAttrIds = product.attrId ? product.attrId.split(",").map((e) => +e) : []
lanbaoming's avatar
lanbaoming committed
962 963
    },
    getProductBrandPage(titleZh = undefined) {
zs嵩's avatar
zs嵩 committed
964
      getProductBrankPage({ pageSize: 20, titleZh }).then((r) => {
lanbaoming's avatar
lanbaoming committed
965 966 967 968
        this.brandList = r.data.list
      })
    },
    getProductBrandPage1(titleZh = undefined) {
zs嵩's avatar
zs嵩 committed
969
      getProductBrankPage({ pageSize: 20, titleZh }).then((r) => {
lanbaoming's avatar
lanbaoming committed
970 971 972
        this.brandList1 = r.data.list
      })
    },
zs嵩's avatar
zs嵩 committed
973
    handleBrandChange(v) {
lanbaoming's avatar
lanbaoming committed
974 975 976 977
      getFeeTypeByOrderProduct({
        brandId: parseInt(v),
        productId: this.warehousing.prodId,
        orderId: this.orderId
zs嵩's avatar
zs嵩 committed
978 979 980 981
      }).then((r) => {
        if (r.code === 0) {
          ;(this.activeName === "first" ? this.form : this.form1).feeType = parseInt(r.data.feeType)
          ;(this.activeName === "first" ? this.form : this.form1).recordMode = parseInt(r.data.recordMode)
lanbaoming's avatar
lanbaoming committed
982 983 984 985 986 987 988 989 990 991 992 993
        }
      })
    },
    handleDelete(val) {
      if (val === 1) {
        this.form1.table.pop()
      } else if (this.form.table.length > this.protectRowCount) {
        this.form.table.pop()
      }
    },
    handleDeleteRow(index, val) {
      if (val === 1) {
zs嵩's avatar
zs嵩 committed
994
        this.form1.table.splice(index, 1)
lanbaoming's avatar
lanbaoming committed
995
      } else if (this.form.table.length > this.protectRowCount) {
zs嵩's avatar
zs嵩 committed
996 997
        this.form.table.splice(index, 1)
      }
lanbaoming's avatar
lanbaoming committed
998 999
    },
    handleAdd(val = 0) {
zs嵩's avatar
zs嵩 committed
1000 1001 1002
      let cartonsNum = ""
      if (val !== 1) {
        // 货物入仓
lanbaoming's avatar
lanbaoming committed
1003
        let hasCartonsNum = 0
zs嵩's avatar
zs嵩 committed
1004
        this.form.table.forEach((e) => {
lanbaoming's avatar
lanbaoming committed
1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017
          hasCartonsNum += e.cartonsNum
        })
        cartonsNum = this.warehousing.num - hasCartonsNum
      }

      const form = val === 1 ? this.form1 : this.form
      const formLength = form.table.length
      let orderLocationBackVOList = []
      /* // 不默认使用上一条记录的储位 https://zentao.test.jdshangmen.com/bug-view-3344.html
      if (formLength > 0) {
        orderLocationBackVOList = JSON.parse(JSON.stringify(form.table[formLength - 1].orderLocationBackVOList))
      }*/
      form.table.push({
zs嵩's avatar
zs嵩 committed
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027
        boxGauge1: this.isJiyun ? 0 : "",
        boxGauge2: this.isJiyun ? 0 : "",
        boxGauge3: this.isJiyun ? 0 : "",
        cartonsNum: cartonsNum > 0 ? cartonsNum : "",
        expressNo: "",
        quantityAll: undefined,
        unit: "1",
        volume: "",
        weight: "",
        specificationType: "1",
lanbaoming's avatar
lanbaoming committed
1028 1029 1030 1031 1032 1033
        table: [],
        orderLocationBackVOList
      })
    },
    /** 获取产品属性列表 */
    getAttrList() {
zs嵩's avatar
zs嵩 committed
1034 1035
      getProductAttrList().then((response) => {
        this.attrList = response.data
lanbaoming's avatar
lanbaoming committed
1036 1037 1038 1039
      })
    },
    /** 获取产品类型列表 */
    getTypeList() {
zs嵩's avatar
zs嵩 committed
1040 1041
      getProductTypeList().then((response) => {
        this.typeList = response.data
lanbaoming's avatar
lanbaoming committed
1042 1043
      })
    },
zs嵩's avatar
zs嵩 committed
1044 1045
    productSubmit() {
      this.$refs["productForm"].validate((valid) => {
lanbaoming's avatar
lanbaoming committed
1046
        if (!valid) {
zs嵩's avatar
zs嵩 committed
1047
          return
lanbaoming's avatar
lanbaoming committed
1048 1049
        }
        //商品特性转字符串
zs嵩's avatar
zs嵩 committed
1050
        this.productForm.attrId = this.productForm.attrArray.join(",")
lanbaoming's avatar
lanbaoming committed
1051
        // 添加的提交
zs嵩's avatar
zs嵩 committed
1052
        addProduct(this.productForm).then((response) => {
lanbaoming's avatar
lanbaoming committed
1053
          this.$modal.msgSuccess(this.$t("新增成功"))
zs嵩's avatar
zs嵩 committed
1054
          if (this.activeName === "first") {
lanbaoming's avatar
lanbaoming committed
1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
            this.form.prodId = response.data
            this.form.warehouseInProdAttrIds = this.productForm.attrArray
          } else {
            this.form1.prodId = response.data
            this.form1.warehouseInProdAttrIds = this.productForm.attrArray
          }
          this.productCancel()
        })
      })
    },
zs嵩's avatar
zs嵩 committed
1065
    productCancel() {
lanbaoming's avatar
lanbaoming committed
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077
      this.isShowProduct = false
      this.productForm = {
        typeId: undefined,
        attrArray: [],
        titleZh: undefined,
        titleEn: undefined
      }
    }
  }
}
</script>

zs嵩's avatar
zs嵩 committed
1078
<style scoped></style>