addShipDetDrawer.vue 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
  1. <template>
  2. <!-- 新增 发运明细 -->
  3. <div id="AddShipDetDrawer">
  4. <a-drawer
  5. title="新增发运明细"
  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="addShipDet" :rules="validatorRules">
  17. <a-row :gutter="24">
  18. <a-col :md="6" :sm="8">
  19. <!-- required 必填项 disabled 禁用 -->
  20. <a-form-model-item label="单据号" prop="documentNo">
  21. <a-input placeholder="自动生成" v-model="addShipDet.documentNo" 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="documentDate">
  26. <a-date-picker
  27. placeholder="请选择单据日期"
  28. format="YYYY-MM-DD"
  29. style="width:100%;"
  30. v-model="addShipDet.documentDate"
  31. />
  32. </a-form-model-item>
  33. </a-col>
  34. <a-col :md="6" :sm="8">
  35. <a-form-model-item label="客户" prop="customer">
  36. <a-input placeholder="请输入客户" v-model="addShipDet.customer"></a-input>
  37. </a-form-model-item>
  38. </a-col>
  39. <!-- <a-col :md="6" :sm="8">
  40. <a-form-model-item label="预发货日期" prop="preDeliveryDate">
  41. <a-date-picker
  42. placeholder="请选择预发货时间"
  43. format="YYYY-MM-DD"
  44. style="width:100%;"
  45. v-model="addShipDet.preDeliveryDate"
  46. />
  47. </a-form-model-item>
  48. </a-col> -->
  49. <!-- <a-col :md="6" :sm="8">
  50. <a-form-model-item label="预完工日期" prop="preCompletionDate">
  51. <a-date-picker
  52. placeholder="请选择预完工日期"
  53. format="YYYY-MM-DD"
  54. style="width:100%;"
  55. v-model="addShipDet.preCompletionDate"
  56. />
  57. </a-form-model-item>
  58. </a-col> -->
  59. <a-col :md="6" :sm="8">
  60. <a-form-model-item label="订单类型" prop="orderType">
  61. <a-input placeholder="请输入订单类型" v-model="addShipDet.orderType"></a-input>
  62. </a-form-model-item>
  63. </a-col>
  64. <!-- <a-col :md="6" :sm="8">
  65. <a-form-model-item label="成衣工厂" prop="garmentFactory">
  66. <a-input placeholder="请输入成衣工厂" v-model="addShipDet.garmentFactory"></a-input>
  67. </a-form-model-item>
  68. </a-col> -->
  69. <!--
  70. <a-col :md="6" :sm="8">
  71. <a-form-model-item label="整单合计" prop="wholeOrderTotal">
  72. <a-input placeholder="整单合计" v-model="addShipDet.wholeOrderTotal"></a-input>
  73. </a-form-model-item>
  74. </a-col> -->
  75. <!-- U8系统适用 -->
  76. <a-col :md="12" :sm="12">
  77. <a-form-model-item label="备注" prop="memo">
  78. <a-input placeholder="U8系统适用" v-model="addShipDet.memo"></a-input>
  79. </a-form-model-item>
  80. </a-col>
  81. </a-row>
  82. </a-form-model>
  83. </div>
  84. </a-card>
  85. <!-- 参照订单数据 増行-->
  86. <a-card :bordered="true" style="margin:10px 0">
  87. <div class="table-operator">
  88. <a-button type="primary" @click.stop="referOrderDataOpen" icon="ordered-list">参照订单数据</a-button>
  89. <!-- <a-button type="primary" @click.stop="handleAddColumn" icon="plus" style="margin-left: 20px">増行</a-button> -->
  90. </div>
  91. <!-- 子表 :model="form" rowKey="id" ,y:800 -->
  92. <a-spin :spinning="confirmLoading">
  93. <a-form-model ref="formRef">
  94. <a-table
  95. :loading="loading"
  96. v-if="syShippingDetailsItemList"
  97. bordered
  98. :rowKey="record => record.id"
  99. :columns="columns"
  100. :data-source="syShippingDetailsItemList"
  101. :pagination="false"
  102. :scroll="{ x: 2800, y: 400 }"
  103. size="small"
  104. >
  105. <!-- 款号 输入框 :rules="rules.itemNumber" -->
  106. <template slot="itemNumber" slot-scope="text, record, index">
  107. <a-form-model-item prop="itemNumber">
  108. <a-input style="width:100%" type="text" v-model="record.itemNumber" readOnly />
  109. </a-form-model-item>
  110. </template>
  111. <!-- 发货数量 :rules="rules.shipQuantity"-->
  112. <template slot="shipmentQuantity" slot-scope="text, record, index">
  113. <a-form-model-item prop="shipmentQuantity">
  114. <a-input style="width:100%" type="text" v-model="record.shipmentQuantity" />
  115. </a-form-model-item>
  116. </template>
  117. <!-- 是否TC功能 :rules="rules.isTC"-->
  118. <!-- isTc ' 是否 tc 功能 0 否 1 是', -->
  119. <template slot="isTC" slot-scope="text, record, index">
  120. <a-form-model-item prop="isTc">
  121. <a-select v-model="record.isTc">
  122. <a-select-option value="">请选择</a-select-option>
  123. <a-select-option value="1">是</a-select-option>
  124. <a-select-option value="0">否</a-select-option>
  125. </a-select>
  126. </a-form-model-item>
  127. </template>
  128. <!-- 物料成分 :rules="rules.materialComposition"-->
  129. <template slot="materialComposition" slot-scope="text, record, index">
  130. <a-form-model-item prop="materialComposition">
  131. <a-input style="width:100%" type="text" v-model="record.materialComposition" />
  132. </a-form-model-item>
  133. </template>
  134. <!-- 采购/委外订单号 :rules="rules.purOrSubOrder"-->
  135. <template slot="purOrSubOrder" slot-scope="text, record, index">
  136. <a-form-model-item prop="purOrSubOrder">
  137. <a-input style="width:100%" type="text" v-model="record.purOrSubOrder" />
  138. </a-form-model-item>
  139. </template>
  140. <!-- 报关单价 :rules="rules.customsDeclarationUnitPrice"-->
  141. <template slot="customsDeclarationUnitPrice" slot-scope="text, record, index">
  142. <a-form-model-item prop="customsDeclarationUnitPrice">
  143. <a-input style="width:100%" type="text" v-model="record.customsDeclarationUnitPrice" />
  144. </a-form-model-item>
  145. </template>
  146. <!-- 套装件数 :rules="rules.numberOfSets"-->
  147. <template slot="numberOfSets" slot-scope="text, record, index">
  148. <a-form-model-item prop="numberOfSets">
  149. <a-input style="width:100%" type="text" v-model="record.numberOfSets" />
  150. </a-form-model-item>
  151. </template>
  152. <!-- 工厂单价 :rules="rules.factoryUnitPrice"-->
  153. <template slot="factoryUnitPrice" slot-scope="text, record, index">
  154. <a-form-model-item prop="factoryUnitPrice">
  155. <a-input style="width:100%" type="text" v-model="record.factoryUnitPrice" />
  156. </a-form-model-item>
  157. </template>
  158. <!--处理方式 -->
  159. <template slot="treatmentMethod" slot-scope="text, record, index">
  160. <a-form-model-item prop="treatmentMethod">
  161. <a-input style="width:100%" type="text" v-model="record.treatmentMethod" />
  162. </a-form-model-item>
  163. </template>
  164. <!--是否手册纱 -->
  165. <template slot="manualYarnFlag" slot-scope="text, record, index">
  166. <a-form-model-item prop="manualYarnFlag">
  167. <a-select v-model="record.manualYarnFlag" @change='changeManualYarnFlag'>
  168. <a-select-option value="">请选择</a-select-option>
  169. <a-select-option :value="1">是</a-select-option>
  170. <a-select-option :value="0">否</a-select-option>
  171. </a-select>
  172. </a-form-model-item>
  173. </template>
  174. <!--手册纱单价 -->
  175. <template slot="manualYarnUnitPrice" slot-scope="text, record, index">
  176. <a-form-model-item prop="manualYarnUnitPrice">
  177. <a-input style="width:100%" type="text" v-model="record.manualYarnUnitPrice" :disabled='manualYarnDisabled' @change="changeManualYarn('Price',record.manualYarnUnitPrice)" />
  178. </a-form-model-item>
  179. </template>
  180. <!--手册纱占比 -->
  181. <template slot="manualYarnProportion" slot-scope="text, record, index">
  182. <a-form-model-item prop="manualYarnProportion">
  183. <a-input style="width:100%" type="text" v-model="record.manualYarnProportion" :disabled='manualYarnDisabled' @change="changeManualYarn('Proportion',record.manualYarnProportion)" />
  184. </a-form-model-item>
  185. </template>
  186. <!-- 操作 -->
  187. <template slot="operationSlot" slot-scope="text, record, index">
  188. <a-popconfirm
  189. v-if="syShippingDetailsItemList.length"
  190. title="确定删除吗?"
  191. @confirm="handleDelete(index)"
  192. >
  193. <a href="javascript:void(0);" style="color:red;">删除</a>
  194. </a-popconfirm>
  195. </template>
  196. </a-table>
  197. </a-form-model>
  198. </a-spin>
  199. </a-card>
  200. <!-- 页面底部保存取消 -->
  201. <div
  202. :style="{
  203. position: 'absolute',
  204. right: 0,
  205. bottom: 0,
  206. width: '100%',
  207. borderTop: '1px solid #e9e9e9',
  208. padding: '10px 16px',
  209. background: '#fff',
  210. textAlign: 'right',
  211. zIndex: 1
  212. }"
  213. >
  214. <a-popconfirm title="确定放弃新增?" @confirm="handleCancel" okText="确定" cancelText="取消">
  215. <a-button :style="{ marginRight: '8px' }">取消</a-button>
  216. </a-popconfirm>
  217. <a-button type="primary" @click="addSave">
  218. 保存
  219. </a-button>
  220. </div>
  221. </a-drawer>
  222. <!-- 参照订单数据弹框 -->
  223. <referOrderData-modal ref="referOrderDataModal" @bao="getSon" @ok="referOrderDataOk" @default-reset="defaultReset"></referOrderData-modal>
  224. </div>
  225. </template>
  226. <script>
  227. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  228. import JEllipsis from '@/components/jeecg/JEllipsis'
  229. import moment from 'moment'
  230. import ReferOrderDataModal from '@views/shipment-details/referOrderDataModal.vue'
  231. import { addShipmentList } from '@api/document/shipmentList'
  232. import { getDotConfig, getDotValidExpress } from '@/utils/myutil'
  233. export default {
  234. name: 'AddShipDetDrawer', // 新增 发运明细 抽屉
  235. mixins: [JeecgListMixin],
  236. components: { JEllipsis, ReferOrderDataModal, moment }, // 参照订单数据 弹框
  237. data() {
  238. let ellipsis = (v, l = 20) => <j-ellipsis value={v} length={l} />
  239. return {
  240. id: '',
  241. validatorRules:{
  242. documentDate:[{required: true, message: '请输入单据日期!'}],
  243. // customer:[{required: true, message: '请选择客户!'}],
  244. // preDeliveryDate:[{required: true, message: '请选择预发货时间!'}],
  245. // preCompletionDate:[{required: true, message: '请选择预完工日期!'}],
  246. // orderType:[{required: true, message: '请输入订单类型!'}],
  247. },
  248. // 表头
  249. columns: [
  250. {
  251. title: '账套',
  252. dataIndex: 'account',
  253. width: 80,
  254. fixed: 'left',
  255. className: 'replacecolor'
  256. },
  257. {
  258. title: '订单号',
  259. dataIndex: 'orderNumber',
  260. width: 120,
  261. fixed: 'left',
  262. className: 'replacecolor'
  263. },
  264. {
  265. title: '款号',
  266. dataIndex: 'itemNumber',
  267. fixed: 'left',
  268. width: 180,
  269. className: 'replacecolor'
  270. },
  271. {
  272. title: '订单日期',
  273. dataIndex: 'orderDate',
  274. width: 120,
  275. className: 'replacecolor',
  276. customRender: text => {
  277. return moment(text).format('YYYY-MM-DD')
  278. }
  279. },
  280. {
  281. title: '预发货日期',
  282. dataIndex: 'preDeliveryDate',
  283. width: 100,
  284. className: 'replacecolor',
  285. },
  286. {
  287. title: '预完工日期',
  288. dataIndex: 'preCompletionDate',
  289. width: 100,
  290. className: 'replacecolor',
  291. },
  292. {
  293. title: '成衣工厂',
  294. dataIndex: 'garmentFactory',
  295. width: 100,
  296. className: 'replacecolor'
  297. },
  298. {
  299. title: '业务类型',
  300. dataIndex: 'businessTypeText',
  301. width: 120,
  302. className: 'replacecolor'
  303. },
  304. {
  305. title: '客户订单',
  306. dataIndex: 'customerOrder',
  307. width: 120,
  308. className: 'replacecolor'
  309. },
  310. {
  311. title: '小po',
  312. dataIndex: 'smallPo',
  313. width: 120,
  314. className: 'replacecolor'
  315. },
  316. {
  317. title: 'Pack Id',
  318. dataIndex: 'packId',
  319. width: 120,
  320. className: 'replacecolor'
  321. },
  322. {
  323. title: '分销点',
  324. dataIndex: 'distributionPoint',
  325. width: 120,
  326. className: 'replacecolor'
  327. },
  328. {
  329. title: '采购/委外订单号',
  330. dataIndex: 'purOrSubOrder',
  331. scopedSlots: { customRender: 'purOrSubOrder' },
  332. // fixed: 'left',
  333. width: 180,
  334. className: 'replacecolor'
  335. },
  336. {
  337. title: ' 报关单价',
  338. dataIndex: 'customsDeclarationUnitPrice',
  339. scopedSlots: { customRender: 'customsDeclarationUnitPrice' },
  340. // fixed: 'left',
  341. width: 180,
  342. className: 'replacecolor'
  343. },
  344. {
  345. title: '订单数量',
  346. dataIndex: 'orderQuantity',
  347. width: 120,
  348. className: 'replacecolor'
  349. },
  350. {
  351. title: '订单剩余数量',
  352. dataIndex: 'orderRemainingQuantity',
  353. width: 120,
  354. className: 'replacecolor'
  355. },
  356. {
  357. title: '发货数量',
  358. dataIndex: 'shipmentQuantity',
  359. scopedSlots: { customRender: 'shipmentQuantity' },
  360. width: 120,
  361. },
  362. {
  363. title: '套装件数',
  364. dataIndex: 'numberOfSets',
  365. scopedSlots: { customRender: 'numberOfSets' },
  366. width: 120,
  367. className: 'replacecolor'
  368. },
  369. {
  370. title: '是否TC功能',
  371. dataIndex: 'isTC',
  372. width: 90,
  373. scopedSlots: { customRender: 'isTC' },
  374. className: 'replacecolor'
  375. },
  376. {
  377. title: '物料成分',
  378. dataIndex: 'materialComposition',
  379. scopedSlots: { customRender: 'materialComposition' },
  380. width: 140,
  381. className: 'replacecolor'
  382. },
  383. {
  384. title: '销售类型',
  385. dataIndex: 'salesTypeText',
  386. width: 120,
  387. className: 'replacecolor'
  388. },
  389. {
  390. title: '客户简称',
  391. dataIndex: 'customerAbbreviation',
  392. width: 220,
  393. align: 'left',
  394. className: 'replacecolor'
  395. },
  396. {
  397. title: '客户名称',
  398. dataIndex: 'customerName',
  399. width: 300,
  400. align: 'left',
  401. className: 'replacecolor',
  402. customRender: t => ellipsis(t),
  403. },
  404. {
  405. title: '汇率',
  406. dataIndex: 'exchangeRate',
  407. width: 120,
  408. className: 'replacecolor'
  409. },
  410. {
  411. title: '销售部门',
  412. dataIndex: 'salesDepartment',
  413. width: 120,
  414. className: 'replacecolor'
  415. },
  416. {
  417. title: '业务员',
  418. dataIndex: 'salesman',
  419. width: 120,
  420. className: 'replacecolor'
  421. },
  422. {
  423. title: '币种',
  424. dataIndex: 'currencyText',
  425. width: 120,
  426. className: 'replacecolor'
  427. },
  428. {
  429. title: '品牌方',
  430. dataIndex: 'brandSide',
  431. width: 180,
  432. className: 'replacecolor'
  433. },
  434. {
  435. title: '第三方',
  436. dataIndex: 'thirdParty',
  437. width: 220,
  438. align: 'left',
  439. className: 'replacecolor'
  440. },
  441. {
  442. title: '定金比例(%)',
  443. dataIndex: 'depositRatio',
  444. width: 120,
  445. className: 'replacecolor'
  446. },
  447. {
  448. title: '定金',
  449. dataIndex: 'deposit',
  450. width: 120,
  451. className: 'replacecolor'
  452. },
  453. {
  454. title: '协同路线',
  455. dataIndex: 'collaborativeRoute',
  456. width: 120,
  457. className: 'replacecolor'
  458. },
  459. {
  460. title: '单价(销售)',
  461. dataIndex: 'salesUnitPrice',
  462. width: 120,
  463. className: 'replacecolor'
  464. },
  465. {
  466. title: '工厂单价',
  467. dataIndex: 'factoryUnitPrice',
  468. width: 120,
  469. scopedSlots: { customRender: 'factoryUnitPrice' },
  470. className: 'replacecolor'
  471. },
  472. {
  473. title: '付款条件',
  474. dataIndex: 'termOfPayment',
  475. width: 160,
  476. customRender: t => ellipsis(t),
  477. className: 'replacecolor'
  478. },
  479. {
  480. title: '最终客户',
  481. dataIndex: 'endCustomer',
  482. width: 120,
  483. className: 'replacecolor'
  484. },
  485. {
  486. title: '订单备注',
  487. dataIndex: 'orderRemarks',
  488. width: 200,
  489. customRender: t => ellipsis(t),
  490. className: 'replacecolor'
  491. },
  492. {
  493. title: '价格备注',
  494. dataIndex: 'priceRemarks',
  495. width: 160,
  496. customRender: t => ellipsis(t),
  497. className: 'replacecolor'
  498. },
  499. {
  500. title: '订单变更说明',
  501. dataIndex: 'orderChangeDescription',
  502. width: 160,
  503. customRender: t => ellipsis(t),
  504. className: 'replacecolor'
  505. },
  506. {
  507. title: '处理方式',
  508. dataIndex: 'treatmentMethod',
  509. width: 160,
  510. scopedSlots: { customRender: 'treatmentMethod' },
  511. className: 'replacecolor'
  512. },
  513. {
  514. title: '是否手册纱',
  515. dataIndex: 'manualYarnFlag',
  516. width: 140,
  517. scopedSlots: { customRender: 'manualYarnFlag' },
  518. className: 'replacecolor'
  519. },
  520. {
  521. title: '手册纱单价',
  522. dataIndex: 'manualYarnUnitPrice',
  523. width: 160,
  524. scopedSlots: { customRender: 'manualYarnUnitPrice' },
  525. className: 'replacecolor'
  526. },
  527. {
  528. title: '手册纱占比',
  529. dataIndex: 'manualYarnProportion',
  530. width: 120,
  531. scopedSlots: { customRender: 'manualYarnProportion' },
  532. className: 'replacecolor'
  533. },
  534. {
  535. title: '操作',
  536. dataIndex: 'operation',
  537. scopedSlots: { customRender: 'operationSlot' },
  538. width: 100,
  539. fixed: 'right',
  540. className: 'replacecolor'
  541. }
  542. ],
  543. monthStartDate:'',//本月第一天日期
  544. syShippingDetailsItemList: [], // 子表数据
  545. msgFormSon: 'test', // 子组件传来数据的变量
  546. manualYarnDisabled: false, //手工纱单价和手工纱占比可输入
  547. addShipDet: {}, // 主表信息
  548. visible: false,
  549. confirmLoading: false,
  550. dateFormat: 'YYYY-MM-DD',
  551. state: '0', // 单据状态初始未【仅保存】
  552. pushState: '0' // 推送状态初始未【仅保存】
  553. // validatorRules: {
  554. // documentNo: [{ required: true, message: '单据号不能为空', trigger: 'blur' }], 单据号
  555. }
  556. },
  557. // 接收父组件查询方法
  558. props: {
  559. fatherList: {
  560. type: Function,
  561. default: null
  562. }
  563. },
  564. methods: {
  565. //默认预发货日期
  566. defalutDate(){
  567. Date.prototype.format = function(fmt) {
  568. var o = {
  569. "M+" : this.getMonth()+1, //月份
  570. "Y+" : this.getFullYear(), //年
  571. "d+" : this.getDate(), //日
  572. "h+" : this.getHours(), //小时
  573. "m+" : this.getMinutes(), //分
  574. "s+" : this.getSeconds(), //秒
  575. "q+" : Math.floor((this.getMonth()+3)/3), //季度
  576. "S" : this.getMilliseconds() //毫秒
  577. };
  578. if(/(Y+)/.test(fmt)) {
  579. fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
  580. }
  581. for(var k in o) {
  582. if(new RegExp("("+ k +")").test(fmt)){
  583. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
  584. }
  585. }
  586. return fmt;
  587. }
  588. var now = new Date(); //当前日期
  589. var nowMonth = now.getMonth(); //当前月
  590. var nowYear = now.getFullYear(); //当前年
  591. //本月的开始时间
  592. this.monthStartDate = new Date(nowYear, nowMonth, 1).format('YYYY-MM-dd');
  593. },
  594. //参照数据重置,恢复默认值
  595. defaultReset() {
  596. this.defalutDate()
  597. this.$refs.referOrderDataModal.range.push(this.monthStartDate)
  598. this.$refs.referOrderDataModal.queryParam.preDeliveryDateS = this.monthStartDate;
  599. this.$refs.referOrderDataModal.queryParam.preDeliveryDateE = '';
  600. },
  601. getSon(val) {
  602. this.manualYarnDisabled = false //初始化manualYarnDisabled
  603. var copyValList = JSON.parse(JSON.stringify(val));
  604. this.addShipDet.customer = copyValList[0].customerName;
  605. console.log(copyValList);
  606. for (var i in copyValList) {
  607. copyValList[i]['orderQuantity'] = copyValList[i].quantity
  608. copyValList[i]['orderRemainingQuantity'] = copyValList[i].surplusNum
  609. copyValList[i]['salesUnitPrice'] = copyValList[i].unitPriceIncludingTax
  610. copyValList[i]['customerOrder'] = copyValList[i].customerOrderNumber
  611. copyValList[i]['shipmentQuantity'] = copyValList[i].surplusNum // 订单剩余数量 赋值给发货数量
  612. }
  613. this.syShippingDetailsItemList = this.syShippingDetailsItemList.concat(copyValList);
  614. this.msgFormSon = this.syShippingDetailsItemList;
  615. },
  616. // 参照订单数据
  617. referOrderDataOpen() {
  618. this.$refs.referOrderDataModal.range = []
  619. if(this.syShippingDetailsItemList.length !== 0){
  620. this.$refs.referOrderDataModal.fatherData.push(this.syShippingDetailsItemList[0])
  621. }
  622. this.$refs.referOrderDataModal.referOrderDataModVis = true
  623. this.defalutDate()
  624. this.$refs.referOrderDataModal.range.push(this.monthStartDate)
  625. this.$refs.referOrderDataModal.queryParam.preDeliveryDateS = this.monthStartDate;
  626. this.$refs.referOrderDataModal.queryParam.preDeliveryDateE = '';
  627. // console.log('点击参照订单数据')
  628. },
  629. // 新增 保存
  630. addSave() {
  631. const that = this;
  632. // 触发表单验证
  633. this.$refs.form.validate(valid => {
  634. if (valid) {
  635. var newObj = {} // 新增对象
  636. newObj.documentNo = this.addShipDet.documentNo
  637. newObj.documentDate = this.addShipDet.documentDate.format('YYYY-MM-DD')
  638. newObj.customer = this.addShipDet.customer
  639. //newObj.preDeliveryDate = this.addShipDet.preDeliveryDate.format('YYYY-MM-DD') // 预发货日期
  640. //newObj.preCompletionDate = this.addShipDet.preCompletionDate.format('YYYY-MM-DD') // 预完工日期
  641. newObj.orderType = this.addShipDet.orderType
  642. newObj.garmentFactory = this.addShipDet.garmentFactory
  643. newObj.wholeOrderTotal = this.addShipDet.wholeOrderTotal
  644. newObj.memo = this.addShipDet.memo // U8系统适用
  645. newObj.syShippingDetailsItemList = this.syShippingDetailsItemList // 子表信息赋值
  646. // 必须选择子表 --- 参照订单数据
  647. if (newObj.syShippingDetailsItemList.length == 0) {
  648. this.$message.error('请选择参照订单数据')
  649. } else {
  650. for (var i=0; i<newObj.syShippingDetailsItemList.length; i++){
  651. var rowData = newObj.syShippingDetailsItemList[i];
  652. if (rowData.shipmentQuantity > rowData.orderRemainingQuantity){
  653. this.$message.error('第'+(i+1)+'行超发货数量超过订单剩余数量,无法保存');
  654. return;
  655. }
  656. }
  657. // 根据syOrderDataItemId判断重复子表id
  658. for (var i=0; i<newObj.syShippingDetailsItemList.length; i++){
  659. var rowData = newObj.syShippingDetailsItemList[i];
  660. for (var j=i+1;j<newObj.syShippingDetailsItemList.length; j++){
  661. var nextData = newObj.syShippingDetailsItemList[j];
  662. if (rowData.smallPo == nextData.smallPo && rowData.orderNumber == nextData.orderNumber &&
  663. rowData.preDeliveryDate == nextData.preDeliveryDate && rowData.preCompletionDate == nextData.preCompletionDate &&
  664. rowData.itemNumber == nextData.itemNumber && rowData.inventoryCode == nextData.inventoryCode&&
  665. rowData.colour == nextData.colour&& rowData.size == nextData.size){
  666. this.$message.error('第'+(i+1)+'行和第'+(j+1)+'行数据相同,无法保存');
  667. return;
  668. }
  669. }
  670. }
  671. for(var i=0; i<newObj.syShippingDetailsItemList.length; i++){
  672. var rowData = newObj.syShippingDetailsItemList[i];
  673. //报关单价不超过四位小数
  674. if(!Number.isInteger(Number(rowData.customsDeclarationUnitPrice)) && rowData.customsDeclarationUnitPrice !== '' && rowData.customsDeclarationUnitPrice !== undefined){
  675. console.log(rowData.customsDeclarationUnitPrice)
  676. var position = rowData.customsDeclarationUnitPrice.toString().indexOf('.') + 1; //小数点的位置
  677. var digit = rowData.customsDeclarationUnitPrice.toString().length - position; //小数的位数
  678. if(digit > 4){
  679. this.$message.error('第'+(i+1)+'行报关单价超过四位小数!');
  680. return
  681. }
  682. }
  683. //发货数量必须是整数
  684. if(!Number.isInteger(Number(rowData.shipmentQuantity)) && rowData.shipmentQuantity !== '' && rowData.shipmentQuantity !== undefined){
  685. this.$message.error('第'+(i+1)+'行发货数量不为整数!');
  686. return
  687. }
  688. //套装件数必须为整数
  689. if(!Number.isInteger(Number(rowData.numberOfSets)) && rowData.numberOfSets !== '' && rowData.numberOfSets !== undefined){
  690. this.$message.error('第'+(i+1)+'行套装件数不为整数!');
  691. return
  692. }
  693. //工厂单价不超过四位小数
  694. if(!Number.isInteger(Number(rowData.factoryUnitPrice)) && rowData.factoryUnitPrice !== '' && rowData.factoryUnitPrice !== undefined){
  695. var position = rowData.factoryUnitPrice.toString().indexOf('.') + 1; //小数点的位置
  696. var digit = rowData.factoryUnitPrice.toString().length - position; //小数的位数
  697. if(digit > 4){
  698. this.$message.error('第'+(i+1)+'行工厂单价超过四位小数!');
  699. return
  700. }
  701. }
  702. //手册纱单价不超过四位小数
  703. if(!Number.isInteger(Number(rowData.manualYarnUnitPrice)) && rowData.manualYarnUnitPrice !== '' && rowData.manualYarnUnitPrice !== undefined){
  704. console.log(rowData.factoryUnitPrice)
  705. var position = rowData.manualYarnUnitPrice.toString().indexOf('.') + 1; //小数点的位置
  706. var digit = rowData.manualYarnUnitPrice.toString().length - position; //小数的位数
  707. if(digit > 4){
  708. this.$message.error('手册纱单价超过四位小数!');
  709. return
  710. }
  711. }
  712. }
  713. //判断当是手册纱时,手册纱单价和手册纱占比是否为空
  714. for (var i=0; i<newObj.syShippingDetailsItemList.length; i++){
  715. var rowData = newObj.syShippingDetailsItemList[i];
  716. if((rowData.manualYarnFlag === 1 && rowData.manualYarnUnitPrice === undefined) || (rowData.manualYarnFlag === 1 && rowData.manualYarnUnitPrice === '') ){
  717. this.$message.error('手册纱单价为必填项');
  718. return
  719. }else if((rowData.manualYarnFlag === 1 && rowData.manualYarnProportion === undefined) || (rowData.manualYarnFlag === 1 && rowData.manualYarnProportion === '') || (rowData.manualYarnFlag === 1 && rowData.manualYarnProportion === "0") || (rowData.manualYarnFlag === 1 && rowData.manualYarnProportion === 0)){
  720. this.$message.error('手册纱占比为必填项');
  721. return
  722. }
  723. }
  724. addShipmentList(newObj).then(res => {
  725. if (res.success) {
  726. this.$message.success('新增成功');
  727. this.close();
  728. // 清空信息
  729. this.addShipDet = {};
  730. this.addShipDet.syShippingDetailsItemList = [];
  731. // this.fatherList(); // 调用父组件 查询方法
  732. // this.msgFormSon = {} 清空子表信息
  733. }else{
  734. this.$message.error(res.message);
  735. }
  736. })
  737. }
  738. }else{
  739. return false;
  740. }
  741. });
  742. // const that = this
  743. // // 触发表单验证
  744. // this.$refs.form.validate(valid => {
  745. // if (valid) {
  746. // that.confirmLoading = true
  747. // }
  748. // })
  749. },
  750. // 校验复制行数量和不能超订单,根据syOrderDataItemId判断
  751. // 増行
  752. // handleAddColumn() {
  753. // console.log('増行')
  754. // const addrow = {
  755. // accountSet: '',
  756. // documentNo: '',
  757. // itemNumber: '',
  758. // orderDate: '',
  759. // businessType: '',
  760. // customerOrder: '',
  761. // smallPo: '',
  762. // packId: '',
  763. // orderDate: '',
  764. // orderRemaQuantity: '',
  765. // shipQuantity: '',
  766. // isTC: '',
  767. // materialComposition: '',
  768. // saleType: '',
  769. // customerShortName: '',
  770. // customerName: '',
  771. // exchangeRate: '',
  772. // wholeSingleCombined: '',
  773. // salesDepartment: '',
  774. // salesman: '',
  775. // currency: '',
  776. // brand: '',
  777. // thirdParty: '',
  778. // depositRate: '',
  779. // deposit: '',
  780. // collaborativeRoute: '',
  781. // paymentClause: '',
  782. // finalCustomer: '',
  783. // orderNote: '',
  784. // priceNote: '',
  785. // orderChangeDesc: '',
  786. // operation: ''
  787. // }
  788. // this.syShippingDetailsItemList.push(addrow)
  789. // },
  790. // --------------------------------------
  791. // 操作 删除
  792. handleDelete(index) {
  793. return this.syShippingDetailsItemList.splice(index, 1)
  794. },
  795. // 操作 复制 复制一行已有的数据
  796. copy(record) {
  797. var newRecord = JSON.parse(JSON.stringify(record));
  798. this.syShippingDetailsItemList.push(newRecord)
  799. },
  800. handleCancel() {
  801. this.close()
  802. },
  803. close() {
  804. this.$emit('close');
  805. this.visible = false;
  806. this.addShipDet = {};
  807. this.syShippingDetailsItemList = [];
  808. },
  809. // 参照订单数据弹框 ok-------------------------------------
  810. referOrderDataOk() {
  811. // console.log('参照订单数据弹框确定')
  812. this.$refs.referOrderDataModal.referOrderDataModVis = false;
  813. this.$refs.referOrderDataModal.queryParam.orderNumber="";
  814. this.$refs.referOrderDataModal.queryParam.account="";
  815. this.$refs.referOrderDataModal.queryParam.salesman="";
  816. this.$refs.referOrderDataModal.queryParam.customerName="";
  817. this.$refs.referOrderDataModal.queryParam.dateRange=[];
  818. this.$refs.referOrderDataModal.queryParam.preDeliveryDate="";
  819. this.$refs.referOrderDataModal.queryParam.flourOrGarment="";
  820. },
  821. //修改是否为手册纱时触发
  822. changeManualYarnFlag(val) {
  823. this.syShippingDetailsItemList.map(item =>{
  824. item.manualYarnFlag = null
  825. item.manualYarnFlag = val
  826. //是手工纱时
  827. if(val === 0){
  828. item.manualYarnUnitPrice = 0
  829. item.manualYarnProportion = 0
  830. this.manualYarnDisabled = true
  831. }else {
  832. this.manualYarnDisabled = false
  833. }
  834. })
  835. this.$forceUpdate()
  836. },
  837. //输入手册纱单价或者手册纱占比时触发
  838. changeManualYarn(data,val){
  839. console.log(this.syShippingDetailsItemList)
  840. this.syShippingDetailsItemList.map(item => {
  841. if(data === 'Price'){item.manualYarnUnitPrice = val}
  842. else{item.manualYarnProportion = val}
  843. })
  844. this.$forceUpdate()
  845. }
  846. }
  847. }
  848. </script>
  849. <style lang="less" scoped>
  850. @import '~@assets/less/common.less';
  851. /deep/ .ant-table-thead > tr > th {
  852. text-align: center;
  853. // font-weight: 700;
  854. }
  855. /deep/ .ant-table-tbody {
  856. text-align: center;
  857. }
  858. // /deep/ th.replacecolor {
  859. // background-color: #ccc;
  860. // }
  861. // 抽屉里的card样式
  862. /deep/ .ant-drawer-content {
  863. background-color: #f0f2f5;
  864. }
  865. /deep/ .ant-drawer-body {
  866. padding: 10px;
  867. }
  868. // 子表下拉显示
  869. /deep/ .ant-card-body {
  870. margin-bottom: 60px;
  871. }
  872. </style>