addAdpackingDrawer.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. <template>
  2. <!-- 新增 预装箱单-成衣-->
  3. <div id="addAdvancePacking">
  4. <a-drawer
  5. :title="(editDecide == 'add')?'新增预装箱单-成衣':'编辑预装箱单-成衣'"
  6. width="89%"
  7. placement="right"
  8. :closable="true"
  9. :visible="visible"
  10. @close="handleCancel"
  11. >
  12. <!-- 主表信息 填写 -->
  13. <a-card :bordered="true">
  14. <div class="table-page-search-wrapper">
  15. <!-- :rules="validatorRules" -->
  16. <a-form-model layout="inline" ref="form" :model="addAdpacking">
  17. <a-row :gutter="24">
  18. <a-col :md="6" :sm="8">
  19. <a-form-model-item label="单据号" prop="documentNo">
  20. {{addAdpacking.documentNo | ellipsis}}
  21. <!-- <a-input placeholder="自动生成" v-model="addAdpacking.orderNumber" readOnly></a-input> -->
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :md="6" :sm="8">
  25. <a-form-model-item label="订单号" prop="orderNumber">
  26. {{addAdpacking.orderNumber | ellipsis}}
  27. <!-- <a-input placeholder="自动生成" v-model="addAdpacking.orderNumber" readOnly></a-input> -->
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :md="6" :sm="8">
  31. <a-form-model-item label="集装箱代号" prop="containerCode">
  32. {{addAdpacking.containerCode | ellipsis}}
  33. <!-- <a-input placeholder="请输入集装箱代号" v-model="addAdpacking.containerCode" readOnly></a-input> -->
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :md="6" :sm="8">
  37. <a-form-model-item label="集装箱号" prop="containerNumber">
  38. {{addAdpacking.containerNumber | ellipsis}}
  39. <!-- <a-input placeholder="请输入集装箱号" v-model="addAdpacking.containerNumber" readOnly></a-input> -->
  40. </a-form-model-item>
  41. </a-col>
  42. <!-- <a-col :md="6" :sm="8">
  43. <a-form-model-item label="预发货日期" prop="u8Remarks">
  44. <j-date placeholder="请选择预发货日期" v-model="addAdpacking.preDeliveryDate" style="width:100%"></j-date>
  45. </a-form-model-item>
  46. </a-col> -->
  47. <a-col :md="6" :sm="8">
  48. <a-form-model-item label="u8备注" prop="u8Remarks">
  49. <a-input placeholder="请输入u8备注" v-model="addAdpacking.u8Remarks"></a-input>
  50. </a-form-model-item>
  51. </a-col>
  52. <a-col :md="6" :sm="8">
  53. <a-form-model-item label="款号" prop="itemNumber">
  54. {{addAdpacking.itemNumber | ellipsis}}
  55. <!-- <a-input placeholder="选择子表自动生成" v-model="addAdpacking.itemNumber"></a-input> -->
  56. </a-form-model-item>
  57. </a-col>
  58. <a-col :md="6" :sm="8">
  59. <a-form-model-item label="中文品名" prop="productName">
  60. {{addAdpacking.productName | ellipsis}}
  61. <!-- <a-input placeholder="选择子表自动生成" v-model="addAdpacking.productName"></a-input> -->
  62. </a-form-model-item>
  63. </a-col>
  64. <a-col :md="6" :sm="8">
  65. <a-form-model-item label="英文品名" prop="productName">
  66. {{addAdpacking.englishProductName | ellipsis}}
  67. <!-- <a-input placeholder="选择子表自动生成" v-model="addAdpacking.englishProductName"></a-input> -->
  68. </a-form-model-item>
  69. </a-col>
  70. <a-col :md="6" :sm="8">
  71. <a-form-model-item label="尺码范围" prop="sizeRange">
  72. {{addAdpacking.sizeRange | ellipsis}}
  73. <!-- <a-input placeholder="选择子表自动生成" v-model="addAdpacking.sizeRange" readOnly></a-input> -->
  74. </a-form-model-item>
  75. </a-col>
  76. <a-col :md="6" :sm="8">
  77. <a-form-model-item label="客户" prop="customer">
  78. {{addAdpacking.customer | ellipsis }}
  79. <!-- <a-input placeholder="选择子表自动生成" v-model="addAdpacking.customer"></a-input> -->
  80. </a-form-model-item>
  81. </a-col>
  82. <!-- <a-col :md="6" :sm="8">
  83. <a-form-model-item label="成衣工厂" prop="garmentFactory">
  84. <a-input placeholder="选择子表自动生成" v-model="addAdpacking.garmentFactory"></a-input>
  85. </a-form-model-item>
  86. </a-col> -->
  87. <a-col :md="6" :sm="8">
  88. <a-form-model-item label="总箱数" prop="totalBoxes">
  89. {{addAdpacking.totalBoxes | ellipsis }}
  90. <!-- <a-input placeholder="自动生成" v-model="addAdpacking.totalBoxes" readOnly></a-input> -->
  91. </a-form-model-item>
  92. </a-col>
  93. <a-col :md="6" :sm="8">
  94. <a-form-model-item label="总净重" prop="totalNetWeight">
  95. {{addAdpacking.totalNetWeight | ellipsis}}
  96. <!-- <a-input placeholder="自动生成" v-model="addAdpacking.totalNetWeight" readOnly></a-input> -->
  97. </a-form-model-item>
  98. </a-col>
  99. <a-col :md="6" :sm="8">
  100. <a-form-model-item label="总毛重" prop="totalGrossWeight">
  101. {{addAdpacking.totalGrossWeight | ellipsis}}
  102. <!-- <a-input placeholder="自动生成" v-model="addAdpacking.totalGrossWeight" readOnly></a-input> -->
  103. </a-form-model-item>
  104. </a-col>
  105. <a-col :md="6" :sm="8">
  106. <a-form-model-item label="总体积" prop="totalVolume">
  107. {{addAdpacking.totalVolume | ellipsis}}
  108. <!-- <a-input placeholder="自动生成" v-model="addAdpacking.totalVolume" readOnly></a-input> -->
  109. </a-form-model-item>
  110. </a-col>
  111. <a-col :md="6" :sm="8">
  112. <a-form-model-item label="总价" prop="totalPrice">
  113. {{addAdpacking.totalPrice | ellipsis}}
  114. <!-- <a-input placeholder="自动生成" v-model="addAdpacking.totalPrice" readOnly></a-input> -->
  115. </a-form-model-item>
  116. </a-col>
  117. <a-col :md="6" :sm="8">
  118. <a-form-model-item label="总件数" prop="totalNumber">
  119. {{addAdpacking.total | ellipsis}}
  120. <!-- <a-input placeholder="自动生成" v-model="addAdpacking.total" readOnly></a-input> -->
  121. </a-form-model-item>
  122. </a-col>
  123. </a-row>
  124. </a-form-model>
  125. </div>
  126. </a-card>
  127. <!-- 参照发运明细 増行-->
  128. <a-card :bordered="false" style="margin:10px 0 60px 0;">
  129. <!-- 子表 ipagination :rules="validatorRules"-->
  130. <a-spin :spinning="confirmLoading">
  131. <a-form-model ref="formRef">
  132. <j-vxe-table
  133. ref="vTable"
  134. toolbar
  135. row-number
  136. row-selection
  137. drag-sort
  138. keep-source
  139. :height="300"
  140. :loading="loading"
  141. :dataSource="addAdpacking.syPreAssembledPackingListItemList"
  142. :columns="columns"
  143. :alwaysEdit=true
  144. :bordered=true
  145. :scroll="{ x: 1500 }"
  146. style="margin-top: 5px;"
  147. :toolbarConfig="toolbarConfig"
  148. @valueChange="handleValueChange"
  149. >
  150. <template v-slot:action="props">
  151. <a @click="copy(props)">复制</a>
  152. <a-divider type="vertical"/>
  153. <a-popconfirm title="确定删除吗?" @confirm="handleDelete(props)">
  154. <a>删除</a>
  155. </a-popconfirm>
  156. </template>
  157. <template v-slot:toolbarSuffix>
  158. <a-button type="primary" @click="referShipmentDetails" icon="ordered-list">参照出运明细</a-button>
  159. </template>
  160. </j-vxe-table>
  161. </a-form-model>
  162. </a-spin>
  163. </a-card>
  164. <!-- 页面底部提交取消 -->
  165. <div
  166. :style="{
  167. position: 'absolute',
  168. right: 0,
  169. bottom: 0,
  170. width: '100%',
  171. borderTop: '1px solid #e9e9e9',
  172. padding: '10px 16px',
  173. background: '#fff',
  174. textAlign: 'right',
  175. zIndex: 1
  176. }"
  177. >
  178. <a-popconfirm title="确定放弃编辑?" @confirm="handleCancel" okText="确定" cancelText="取消">
  179. <a-button :style="{ marginRight: '8px' }">取消</a-button>
  180. </a-popconfirm>
  181. <a-button type="primary" @click="myHandSave" :loading="btnLoading" v-preventReClick="2000">
  182. 保存
  183. </a-button>
  184. <a-button type="primary" @click="myHandSubmit" style="margin-left: 8px">
  185. 保存并提交
  186. </a-button>
  187. </div>
  188. </a-drawer>
  189. <!-- 参照发运明细弹框 -->
  190. <referShipmentDetails-modal
  191. ref="referShipmentDetailsModal"
  192. @bao="getSon"
  193. @ok="modalFormOk"
  194. ></referShipmentDetails-modal>
  195. </div>
  196. </template>
  197. <script>
  198. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  199. import JEllipsis from '@/components/jeecg/JEllipsis'
  200. import moment from 'moment'
  201. import ReferShipmentDetailsModal from '@views/advance-packingList/referShipmentDetailsModal.vue'
  202. import { addAdvPac, editById } from '@api/document/advance-packingList.js'
  203. import { queryShippingDetails } from '@api/document/advance-packingList.js'
  204. import { JVXETypes } from '@/components/jeecg/JVxeTable'
  205. import { pushIfNotExist, randomNumber, randomUUID } from '@/utils/util'
  206. import { getDotConfig, getDotValidExpress } from '@/utils/myutil'
  207. export default {
  208. name: 'AddAdvancePacking', // 新增预装箱单
  209. mixins: [JeecgListMixin],
  210. components: { JEllipsis, moment, ReferShipmentDetailsModal }, // 参照发运明细弹框
  211. data() {
  212. let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} /> // 省略
  213. return {
  214. toolbarConfig: {
  215. // add 新增按钮;remove 删除按钮;clearSelection 清空选择按钮
  216. btn: []
  217. },
  218. btnLoading:false,//按钮等待状态
  219. // 表头
  220. columns: [
  221. {
  222. title: '账套',
  223. key: 'acSetNo',
  224. width: 120,
  225. fixed: 'left',
  226. type: JVXETypes.normal,
  227. },
  228. {
  229. title: '成衣工厂',
  230. key: 'garmentFactory',
  231. width: 120,
  232. fixed: 'left',
  233. type: JVXETypes.normal,
  234. },
  235. {
  236. title: 'HOD',
  237. key: 'hod',
  238. width: 120,
  239. fixed: 'left',
  240. type: JVXETypes.normal,
  241. },
  242. {
  243. title: 'STYLE NO.',
  244. key: 'styleNo',
  245. width: 120,
  246. type: JVXETypes.normal,
  247. },
  248. {
  249. title: 'PO NO.',
  250. key: 'poNo',
  251. width: 120,
  252. type: JVXETypes.normal,
  253. },
  254. {
  255. title: 'ITEM NO./SKU NO./UPC NO./PACKS CODE',
  256. key: 'itemCode',
  257. width: 340,
  258. type: JVXETypes.input,
  259. },
  260. {
  261. title: '分销点/DC/LABEL',
  262. key: 'distributionPoint',
  263. width: 180,
  264. type: JVXETypes.normal,
  265. },
  266. {
  267. title: 'PREPACK SKU',
  268. key: 'prepackSku',
  269. width: 140,
  270. type: JVXETypes.input,
  271. insertAfter:true,
  272. },
  273. {
  274. title: '起始箱号',
  275. key: 'startingBoxNumber',
  276. width: 120,
  277. type: JVXETypes.inputNumber ,
  278. },
  279. {
  280. title: '结束箱号',
  281. key: 'endCaseNumber',
  282. width: 140,
  283. type: JVXETypes.inputNumber ,
  284. },
  285. {
  286. title: '颜色(中英文)',
  287. key: 'colour',
  288. width: 140,
  289. type: JVXETypes.input ,
  290. },
  291. {
  292. title: '配码--根据U8订单来显示',
  293. key: 'withCode',
  294. width: 240,
  295. type: JVXETypes.normal ,
  296. },
  297. {
  298. title: '计划尺码数量',
  299. key: 'planSize',
  300. width: 240,
  301. type: JVXETypes.normal ,
  302. },
  303. {
  304. title: '计划装箱数量',
  305. key: 'planQuantity',
  306. width: 240,
  307. type: JVXETypes.normal ,
  308. },
  309. {
  310. title: '件数/箱',
  311. key: 'piecesBox',
  312. width: 90,
  313. type: JVXETypes.normal ,
  314. },
  315. {
  316. title: '箱数',
  317. key: 'boxNumber',
  318. width: 140,
  319. type: JVXETypes.normal ,
  320. },
  321. {
  322. title: '总件数',
  323. key: 'total',
  324. width: 140,
  325. type: JVXETypes.normal,
  326. },
  327. {
  328. title: '净重/箱',
  329. key: 'netWeight',
  330. width: 90,
  331. type: JVXETypes.inputNumber,
  332. },
  333. {
  334. title: '总净重',
  335. key: 'totalNetWeight',
  336. width: 140,
  337. type: JVXETypes.normal,
  338. },
  339. {
  340. title: '毛重/箱',
  341. key: 'grossWeight',
  342. width: 120,
  343. type: JVXETypes.inputNumber,
  344. },
  345. {
  346. title: '总毛重',
  347. key: 'totalGrossWeight',
  348. width: 140,
  349. type: JVXETypes.normal,
  350. },
  351. {
  352. title: '外箱长度',
  353. key: 'outerBoxLength',
  354. width: 120,
  355. type: JVXETypes.inputNumber
  356. },
  357. {
  358. title: '外箱宽度',
  359. key: 'outerBoxWidth',
  360. width: 140,
  361. type: JVXETypes.inputNumber,
  362. },
  363. {
  364. title: '外箱高度',
  365. key: 'outerBoxHeight',
  366. type: JVXETypes.inputNumber ,
  367. width: 140,
  368. },
  369. {
  370. title: '总体积',
  371. key: 'totalVolume',
  372. type: JVXETypes.normal ,
  373. width: 140,
  374. },
  375. {
  376. title: '净净重',
  377. key: 'netWeightToo',
  378. width: 120,
  379. type: JVXETypes.inputNumber,
  380. },
  381. {
  382. title: '单价',
  383. key: 'unitPrice',
  384. width: 120,
  385. type: JVXETypes.normal,
  386. },
  387. {
  388. title: '总价',
  389. key: 'totalPrice',
  390. width: 120,
  391. type: JVXETypes.normal,
  392. // validateRules: [{ required: true, message: '${title}不能为空' },
  393. // {pattern: /^\d+(\.\d{1,2})?$/, message: '小数点位数不能超过2位' }],
  394. },
  395. {
  396. title: '备注',
  397. key: 'memo',
  398. width: 120,
  399. type: JVXETypes.normal,
  400. // validateRules: [{ required: true, message: '${title}不能为空' },
  401. // {pattern: /^\d+(\.\d{1,2})?$/, message: '小数点位数不能超过2位' }],
  402. },
  403. {
  404. title: '操作',
  405. key: 'action',
  406. type: JVXETypes.slot,
  407. fixed: 'right',
  408. width: 160,
  409. align: 'center',
  410. slotName: 'action',
  411. }
  412. ],
  413. row:{},
  414. loading: false, // 表格加载
  415. visible: false,
  416. editDecide: 'add',
  417. dateFormat: 'YYYY-MM-DD',
  418. addAdpacking: {
  419. syPreAssembledPackingListItemList:[]
  420. }, //主表信息
  421. confirmLoading: false,
  422. msgFormSon: 'test', // 子组件传来数据的变量
  423. // state: '0', // 单据状态初始未【仅保存】
  424. // pushState: '0' // 推送状态初始未【仅保存】
  425. // 待确定还有哪些必填信息 ----------------------------
  426. // validatorRules: {
  427. // orderNumber: [{ required: true, message: '订单号不能为空', trigger: 'blur' }],
  428. // styleNum: [{ required: true, message: '款号不能为空', trigger: 'blur' }],
  429. // name: [{ required: true, message: '品名不能为空', trigger: 'blur' }]
  430. // },
  431. sizeFields:[], // 尺码字段
  432. dotConfig:{}, // 小数点配置
  433. judge : 0 ,
  434. }
  435. },
  436. // 接收父组件查询方法
  437. props: {
  438. fatherList: {
  439. type: Function,
  440. default: null
  441. }
  442. },
  443. methods: {
  444. getSon(val) {
  445. // console.log('勾选发运明细数据', val)
  446. // for (var i in val) {
  447. // val[i]['orderQuantity'] = val[i].quantity
  448. // val[i]['orderRemainingQuantity'] = val[i].surplusNum
  449. // val[i]['salesUnitPrice'] = val[i].unitPriceIncludingTax
  450. // val[i]['customerOrder'] = val[i].customerOrderNumber
  451. // val[i]['shipmentQuantity'] = val[i].surplusNum //订单剩余数量 赋值给发货数量
  452. // }
  453. this.addAdpacking.syPreAssembledPackingListItemList = [];
  454. this.setHeadCalField();
  455. var selectData = val[0];
  456. queryShippingDetails({id:selectData.id,groupId:selectData.groupId}).then(res => {
  457. if (res.success) {
  458. // 放在前面,有小数位数设置
  459. this.setHeadData(val[0], res.result);
  460. this.loadSizeTables(res.result.sizeTables);
  461. var changedData = this.changeData(val[0], res.result);
  462. this.addAdpacking.syPreAssembledPackingListItemList.push(changedData);
  463. }else{
  464. this.$message.error("获取发运明细详情失败");
  465. }
  466. })
  467. },
  468. loadSizeTables(sizeTable){
  469. var newColums = this.columns.filter(item=>{
  470. return item.isSize != true;
  471. });
  472. this.sizeFields = [];
  473. if (sizeTable != null){
  474. var i=0;
  475. // 找到插入位置点
  476. for (; i<newColums.length;i++){
  477. if (newColums[i].insertAfter){
  478. break;
  479. }
  480. }
  481. // 插入数据
  482. for (var j=0;j<sizeTable.length;j++){
  483. this.sizeFields.push('size-'+sizeTable[j].size);
  484. var validExpress = getDotValidExpress(this.dotConfig.quantity);
  485. var field = {
  486. title: sizeTable[j].size,
  487. key: 'size-'+sizeTable[j].size,
  488. type: JVXETypes.inputNumber ,
  489. width: 80,
  490. isSize:true,
  491. validateRules: [validExpress]
  492. };
  493. newColums.splice(i+1+j,0,field);
  494. }
  495. }
  496. this.columns = newColums;
  497. },
  498. // 参照发运明细
  499. referShipmentDetails() {
  500. // console.log('打开参照发运明细')
  501. this.$refs.referShipmentDetailsModal.referShipDetModVis = true
  502. },
  503. myHandSave(){
  504. this.addAdpacking.status=0;
  505. this.saveAdd();
  506. },
  507. async myHandSubmit(){
  508. this.addAdpacking.status=1;
  509. this.saveAdd();
  510. },
  511. // 保存
  512. async saveAdd() {
  513. var newObj = this.addAdpacking;
  514. if (this.sizeFields.length == 0){
  515. this.$message.error('当前记录没有尺码字段,无法保存');
  516. return;
  517. }
  518. // if (newObj.totalBoxes == 0){
  519. // this.$message.error('总箱数为0,无法保存');
  520. // return;
  521. // }
  522. await this.JudgeVluabled()
  523. //尺码赋值
  524. for(var i =0;i<newObj.syPreAssembledPackingListItemList.length;i++){
  525. var dataTable = newObj.syPreAssembledPackingListItemList[i]
  526. for (var j=0; j<dataTable.sizeTables.length; j++){
  527. var sizeTable = dataTable.sizeTables[j];
  528. var field = 'size-'+sizeTable.size;
  529. dataTable.sizeTables[j].proportion = dataTable[field];
  530. }
  531. }
  532. // 日期格式转换
  533. if (newObj.preDeliveryDate != "" && newObj.preDeliveryDate != undefined){
  534. newObj.preDeliveryDate = newObj.preDeliveryDate+" 00:00:00";
  535. }
  536. // 推送状态、状态赋默认值。新增状态赋值
  537. if (newObj.id == undefined || newObj.id == ""){
  538. newObj.push_status = 0;
  539. }
  540. if(this.judge == 0){
  541. if(this.editDecide === 'edit'){
  542. editById(newObj).then(res => {
  543. this.btnLoading = true
  544. if (res.success) {
  545. if(newObj.status == '1'){
  546. this.$message.success('编辑并提交成功')
  547. }else {
  548. this.$message.success('编辑成功')
  549. }
  550. this.close()
  551. this.btnLoading = false
  552. //清空信息
  553. newObj = {syPreAssembledPackingListItemList:[]};
  554. this.row = res.result
  555. this.fatherList() // 调用父组件 查询方法
  556. // this.msgFormSon = {} 清空子表信息
  557. }else{
  558. this.$message.error(res.message)
  559. this.btnLoading = false
  560. }
  561. })
  562. }else {
  563. addAdvPac(newObj).then(res => {
  564. this.btnLoading = true
  565. if (res.success) {
  566. if(newObj.status == '1'){
  567. this.$message.success('新增并提交成功')
  568. }else {
  569. this.$message.success('新增成功')
  570. }
  571. this.close()
  572. this.btnLoading = false
  573. //清空信息
  574. newObj = {syPreAssembledPackingListItemList:[]};
  575. this.row = res.result
  576. this.fatherList() // 调用父组件 查询方法
  577. // this.msgFormSon = {} 清空子表信息
  578. }else{
  579. this.$message.error(res.message)
  580. this.btnLoading = false
  581. }
  582. })
  583. }
  584. }
  585. // const that = this
  586. // // 触发表单验证
  587. // this.$refs.form.validate(valid => {
  588. // if (valid) {
  589. // that.confirmLoading = true
  590. // }
  591. // })
  592. },
  593. JudgeVluabled(){
  594. this.judge = 0
  595. for (var i=0; i<this.addAdpacking.syPreAssembledPackingListItemList.length;i++){
  596. var tableRow = this.addAdpacking.syPreAssembledPackingListItemList[i];
  597. tableRow = JSON.parse(JSON.stringify(tableRow))
  598. var allSizeSum = this.getAllSizeSum(tableRow);
  599. if (allSizeSum == 0){
  600. this.$message.error('第'+(i+1)+'行所有尺码数量为0,无法保存');
  601. this.judge += 1
  602. return;
  603. }
  604. if(tableRow.startingBoxNumber > tableRow.endCaseNumber) {
  605. this.$message.error('第'+(i+1)+'行起始箱号大于结束箱号,无法保存');
  606. this.judge += 1
  607. return;
  608. }
  609. //是否未填
  610. var required = [
  611. {key:'startingBoxNumber',value:'起始箱号'},
  612. {key:'endCaseNumber',value:'结束箱号'},
  613. {key:'netWeight',value:'净重/箱'},
  614. {key:'grossWeight',value:'毛重/箱'},
  615. {key:'outerBoxLength',value:'外箱长度'},
  616. {key:'outerBoxHeight',value:'外箱高度'},
  617. {key:'outerBoxWidth',value:'外箱宽度'},
  618. {key:'netWeightToo',value:'净净重'},
  619. ]
  620. for(var j=0 ; j<required.length;j++){
  621. if(tableRow[required[j].key] == null || tableRow[required[j].key] == "" || tableRow[required[j].key] == undefined){
  622. this.$message.error('第'+(i+1)+'行'+required[j].value+'无值,无法保存');
  623. this.judge+=1
  624. return
  625. }
  626. }
  627. //是否为整
  628. var integer = [
  629. {key:'startingBoxNumber',value:'起始箱号'},
  630. {key:'endCaseNumber',value:'结束箱号'},
  631. {key:'piecesBox',value:'件数/箱'},
  632. ]
  633. for(var v=0 ; v<integer.length;v++){
  634. if(!Number.isInteger(Number(tableRow[integer[v].key]))){
  635. this.$message.error('第'+(i+1)+'行'+integer[v].value+'不为整数,无法保存');
  636. this.judge+=1
  637. return
  638. }
  639. }
  640. //判断小数位数
  641. var Several = [
  642. {key:'netWeight',value:'净重/箱'},
  643. {key:'grossWeight',value:'毛重/箱'},
  644. {key:'netWeightToo',value:'净净重'}
  645. ]
  646. for(var s=0 ; s<Several.length;s++){
  647. var position = tableRow[Several[s].key].toString().indexOf('.') + 1; //小数点的位置
  648. var digit = tableRow[Several[s].key].toString().length - position; //小数的位值
  649. if(digit > 2 && position!==0 ){
  650. this.$message.error('第'+(i+1)+'行'+Several[s].value+'小数超过两位,无法保存');
  651. this.judge+=1
  652. return
  653. }
  654. }
  655. }
  656. },
  657. // 设置表头信息
  658. setHeadData(referData, mData){
  659. var itemData = {};
  660. if (mData.syPreAssembledPackingListItemList != null && mData.syPreAssembledPackingListItemList.size>0){
  661. itemData = mData.syPreAssembledPackingListItemList[0];
  662. }
  663. // 设置件数小数位数
  664. this.dotConfig = getDotConfig(itemData.masterMetering);
  665. this.addAdpacking.syDeclarationElementsId = mData.syDeclarationElementsId;
  666. this.addAdpacking.elementsId = mData.elementsId
  667. this.addAdpacking.itemNumber = referData.itemNumber;
  668. // this.addAdpacking.productName = referData.chineseName;
  669. this.addAdpacking.productName = mData.productName;
  670. this.addAdpacking.englishProductName = mData.englishProductName;
  671. this.addAdpacking.u8Remarks = mData.u8Remarks;
  672. this.addAdpacking.sizeRange = "";
  673. if (mData.sizeTables != null){
  674. if (mData.sizeTables.length == 1){
  675. this.addAdpacking.sizeRange = mData.sizeTables[0].size;
  676. }else if (mData.sizeTables.length>1){
  677. this.addAdpacking.sizeRange = mData.sizeTables[0].size + " ~ " + mData.sizeTables[mData.sizeTables.length-1].size;
  678. }
  679. }
  680. this.addAdpacking.customer = mData.customer;
  681. this.addAdpacking.ompoId = mData.ompoId
  682. this.addAdpacking.salesman = mData.salesman
  683. this.addAdpacking.customerAbbreviation = mData.customerAbbreviation
  684. this.addAdpacking.spurOrSubOrder = mData.spurOrSubOrder
  685. this.addAdpacking.garmentFactory = mData.garmentFactory;
  686. this.addAdpacking.orderNumber = mData.orderNumber
  687. },
  688. // 发运明细详情成预装箱记录:mData-主表记录,itemData-子表记录
  689. changeData(referData, mData) {
  690. var itemData = {};
  691. if (mData.syPreAssembledPackingListItemList != null && mData.syPreAssembledPackingListItemList.length>0){
  692. itemData = mData.syPreAssembledPackingListItemList[0];
  693. }
  694. var addrow = {
  695. syDeclarationElementsId:itemData.syDeclarationElementsId,
  696. syDeclarationElementsItemId:itemData.syDeclarationElementsItemId,
  697. acSetNo: itemData.acSetNo,
  698. garmentFactory: itemData.garmentFactory,
  699. hod: itemData.hod,
  700. styleNo:itemData.styleNo,
  701. poNo:itemData.poNo,
  702. itemCode:'',
  703. distributionPoint:referData.distributionPoint,
  704. prepackSku: '',
  705. size:"",
  706. startingBoxNumber: '',
  707. endCaseNumber: '',
  708. colour: itemData.colour,
  709. withCode: itemData.withCode,
  710. piecesBox: 0,
  711. boxNumber: '',
  712. total: '',
  713. netWeight: '',
  714. totalNetWeight: '',
  715. grossWeight: '',
  716. totalGrossWeight: '',
  717. outerBoxLength: '',
  718. outerBoxWidth: '',
  719. outerBoxHeight: '',
  720. totalVolume: '',
  721. netWeightToo: '',
  722. unitPrice: itemData.unitPrice,
  723. totalPrice: '',
  724. smallPo: referData.smallPo,
  725. inventoryName:referData.inventoryName,
  726. spurOrSubOrder:referData.purOrSubOrder,
  727. factoryUnitPrice:referData.factoryUnitPrice,
  728. customerAbbreviation:referData.customerAbbreviation,
  729. sizeTables : itemData.sizeTables,
  730. planSize : itemData.planSize,
  731. planQuantity:itemData.planQuantity,
  732. supplierCode:itemData.supplierCode,
  733. supplier:itemData.supplier,
  734. ompoAccount:itemData.ompoAccount,
  735. ompoId:itemData.ompoId,
  736. ompoIdItem:itemData.ompoIdItem,
  737. ymoney:itemData.ymoney
  738. }
  739. return addrow;
  740. },
  741. // 操作按钮 删除
  742. handleDelete(index) {
  743. var ret = this.addAdpacking.syPreAssembledPackingListItemList.splice(index.rowIndex, 1);
  744. this.setHeadCalField();
  745. return ret;
  746. },
  747. // 复制
  748. copy(record) {
  749. var newRow = JSON.parse(JSON.stringify(record.row));
  750. newRow.isAdd = 1
  751. this.addAdpacking.syPreAssembledPackingListItemList.push(newRow);
  752. this.setHeadCalField();
  753. },
  754. // 抽屉 取消
  755. handleCancel() {
  756. this.close()
  757. },
  758. close() {
  759. this.$emit('close')
  760. this.visible = false;
  761. this.btnLoading = false
  762. this.editDecide = 'add'
  763. this.addAdpacking = {syPreAssembledPackingListItemList:[]};
  764. },
  765. aa() {},
  766. modalFormOk() {
  767. this.$refs.referShipmentDetailsModal.referShipmentDetailsModVis = true
  768. },
  769. // 表格字段值变动时触发
  770. handleValueChange(event) {
  771. if (event.row.startingBoxNumber != undefined && event.row.startingBoxNumber != "" &&
  772. event.row.endCaseNumber != undefined && event.row.endCaseNumber != ""){
  773. event.row.boxNumber = event.row.endCaseNumber*1-event.row.startingBoxNumber*1+1;
  774. }
  775. var allSizeSum = this.getAllSizeSum(event.row);
  776. event.row.piecesBox = allSizeSum;
  777. event.row.total = (event.row.piecesBox*event.row.boxNumber);
  778. if (event.row.unitPrice != undefined && event.row.unitPrice != ""){
  779. event.row.totalPrice = (event.row.unitPrice*event.row.total).toFixed(2);
  780. }
  781. if (event.row.netWeight != "" && event.row.netWeight != undefined){
  782. event.row.totalNetWeight = (event.row.netWeight * event.row.boxNumber).toFixed(2);
  783. }
  784. if (event.row.grossWeight != "" && event.row.grossWeight != undefined){
  785. event.row.totalGrossWeight = (event.row.grossWeight * event.row.boxNumber).toFixed(2);
  786. }
  787. if (event.row.outerBoxLength != "" && event.row.outerBoxLength != undefined &&
  788. event.row.outerBoxWidth != "" && event.row.outerBoxWidth != undefined &&
  789. event.row.outerBoxHeight != "" && event.row.outerBoxHeight != undefined){
  790. event.row.totalVolume = ((event.row.outerBoxLength * event.row.outerBoxWidth * event.row.outerBoxHeight * event.row.boxNumber)/1000000).toFixed(3);
  791. }
  792. this.$forceUpdate()
  793. this.setHeadCalField();
  794. },
  795. // 获取不同尺码数量之和
  796. getAllSizeSum(record){
  797. var ret = 0;
  798. for (var i=0; i<this.sizeFields.length; i++){
  799. if (record[this.sizeFields[i]] != undefined && record[this.sizeFields[i]] != ""){
  800. ret += record[this.sizeFields[i]]*1;
  801. }
  802. }
  803. return ret;
  804. },
  805. // 设置表头计算值,直接设置表头值对象不能刷新,把表头对象换了就可以了
  806. setHeadCalField(){
  807. var headData = JSON.parse(JSON.stringify(this.addAdpacking));
  808. var totalBoxes = 0;
  809. var totalNetWeight = 0;
  810. var totalGrossWeight = 0;
  811. var totalVolume = 0;
  812. var totalPrice = 0;
  813. var total = 0;
  814. for (var i=0; i<headData.syPreAssembledPackingListItemList.length; i++){
  815. var rowData = headData.syPreAssembledPackingListItemList[i];
  816. totalBoxes += rowData.boxNumber;
  817. if (rowData.totalNetWeight != undefined && rowData.totalNetWeight != ""){
  818. totalNetWeight += rowData.totalNetWeight*1;
  819. }
  820. if (rowData.totalGrossWeight != undefined && rowData.totalGrossWeight != ""){
  821. totalGrossWeight += rowData.totalGrossWeight*1;
  822. }
  823. if (rowData.totalVolume != undefined && rowData.totalVolume != ""){
  824. totalVolume += rowData.totalVolume*1;
  825. }
  826. if (rowData.totalPrice != undefined && rowData.totalPrice != ""){
  827. totalPrice += rowData.totalPrice*1;
  828. }
  829. if (rowData.total != undefined && rowData.total != ""){
  830. total += rowData.total*1;
  831. }
  832. }
  833. headData.totalBoxes = totalBoxes.toFixed(0);
  834. headData.totalNetWeight = totalNetWeight;
  835. headData.totalGrossWeight = totalGrossWeight;
  836. headData.totalVolume = totalVolume.toFixed(3);
  837. headData.totalPrice = totalPrice.toFixed(2);
  838. headData.total = total.toFixed(0)
  839. this.addAdpacking = headData;
  840. },
  841. },
  842. computed: {},
  843. mounted() {}
  844. }
  845. </script>
  846. <style lang="less" scoped>
  847. @import '~@assets/less/common.less';
  848. /deep/ .ant-table-thead > tr > th {
  849. text-align: center;
  850. // font-weight: 700;
  851. }
  852. /deep/ .ant-table-tbody {
  853. text-align: center;
  854. }
  855. // /deep/ th.replacecolor {
  856. // background-color: #ccc;
  857. // }
  858. // 抽屉里的card样式
  859. /deep/ .ant-drawer-content {
  860. background-color: #f0f2f5;
  861. }
  862. /deep/ .ant-drawer-body {
  863. padding: 10px;
  864. }
  865. </style>