inventoryTable.vue 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551
  1. <template>
  2. <el-form ref="form" :model="form" :rules="rules">
  3. <ele-pro-table
  4. ref="table"
  5. :needPage="false"
  6. :columns="columns"
  7. @columns-change="handleColumnChange"
  8. :cache-key="cacheKeyUrl"
  9. max-height="500px"
  10. :datasource="form.datasource"
  11. class="time-form"
  12. >
  13. <!-- 表头工具栏 -->
  14. <template v-slot:toolbar>
  15. <div class="headbox">
  16. <div>
  17. <el-button
  18. size="small"
  19. type="primary"
  20. icon="el-icon-plus"
  21. class="ele-btn-icon"
  22. @click="handParent('', -1)"
  23. v-if="!isContractId"
  24. >
  25. 新增
  26. </el-button>
  27. </div>
  28. </div>
  29. </template>
  30. <template v-slot:requirementTotalCount="{ row, $index }">
  31. <el-link
  32. type="primary"
  33. :underline="false"
  34. @click="handleGetBillDetail(row, 1)"
  35. >
  36. {{ row.purchaseCount }}
  37. </el-link>
  38. </template>
  39. <template v-slot:planTotalCount="{ row, $index }">
  40. <el-link
  41. type="primary"
  42. :underline="false"
  43. @click="handleGetBillDetail(row, 2)"
  44. >
  45. {{ row.planTotalCount }}
  46. </el-link>
  47. </template>
  48. <template v-slot:inquiryTotalCount="{ row, $index }">
  49. <el-link
  50. type="primary"
  51. :underline="false"
  52. @click="handleGetBillDetail(row, 3)"
  53. >
  54. {{ row.inquiryTotalCount }}
  55. </el-link>
  56. </template>
  57. <template v-slot:contractTotalCount="{ row, $index }">
  58. <el-link
  59. type="primary"
  60. :underline="false"
  61. @click="handleGetBillDetail(row, 4)"
  62. >
  63. {{ row.contractTotalCount }}
  64. </el-link>
  65. </template>
  66. <template v-slot:doneTotalCount="{ row, $index }">
  67. <el-link
  68. type="primary"
  69. :underline="false"
  70. @click="handleGetBillDetail(row, 5)"
  71. >
  72. {{ row.doneTotalCount }}
  73. </el-link>
  74. </template>
  75. <template v-slot:waitTotalCount="{ row, $index }">
  76. <el-link
  77. type="primary"
  78. :underline="false"
  79. @click="handleGetBillDetail(row, 6)"
  80. >
  81. {{ row.waitTotalCount }}
  82. </el-link>
  83. </template>
  84. <template v-slot:taskName="scope">
  85. <el-form-item
  86. style="margin-bottom: 20px"
  87. :prop="'datasource.' + scope.$index + '.taskName'"
  88. >
  89. <span>
  90. {{ scope.row.taskName }}
  91. </span>
  92. <el-button
  93. v-if="scope.row.productCode"
  94. size="small"
  95. type="primary"
  96. @click.native="handleTaskinstance(scope.row, scope.$index)"
  97. >选择
  98. </el-button>
  99. </el-form-item>
  100. </template>
  101. <template v-slot:productName="{ row, $index }">
  102. <div @click="handParent(row, $index)">
  103. {{ row.productName }}
  104. </div>
  105. </template>
  106. <template v-slot:taxRate="scope">
  107. <el-form-item
  108. style="margin-bottom: 20px"
  109. :prop="'datasource.' + scope.$index + '.taxRate'"
  110. >
  111. <el-input v-model="scope.row.taxRate" @input="getNotaxSinglePrice">
  112. <template slot="append">%</template>
  113. </el-input>
  114. </el-form-item>
  115. </template>
  116. <template v-slot:totalPrice="scope">
  117. <el-form-item
  118. style="margin-bottom: 20px"
  119. :prop="'datasource.' + scope.$index + '.totalPrice'"
  120. >
  121. {{ (Number(scope.row.totalPrice) || 0).toFixed(2) }}元
  122. </el-form-item>
  123. </template>
  124. <template v-slot:specification="scope">
  125. <el-form-item
  126. style="margin-bottom: 20px"
  127. :prop="'datasource.' + scope.$index + '.specification'"
  128. >
  129. <el-input v-model="scope.row.specification"></el-input>
  130. </el-form-item>
  131. </template>
  132. <template v-slot:guaranteePeriod="scope">
  133. <div class="period">
  134. <div class="borderleftnone">
  135. <el-form-item
  136. style="margin-bottom: 20px"
  137. :prop="'datasource.' + scope.$index + '.guaranteePeriod'"
  138. :rules="{
  139. pattern: numberReg,
  140. message: '请输入数字',
  141. trigger: 'blur'
  142. }"
  143. >
  144. <el-input
  145. v-model="scope.row.guaranteePeriod"
  146. @change="
  147. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  148. "
  149. placeholder="请输入"
  150. ></el-input>
  151. </el-form-item>
  152. </div>
  153. <div class="borderrightnone">
  154. <DictSelection
  155. dictName="质保期单位"
  156. clearable
  157. v-model="scope.row.guaranteePeriodUnitCode"
  158. :isOne="scope.$index === 0"
  159. @change="
  160. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  161. "
  162. >
  163. </DictSelection>
  164. </div>
  165. </div>
  166. </template>
  167. <template v-slot:measuringUnit="scope">
  168. <el-form-item
  169. style="margin-bottom: 20px"
  170. :prop="'datasource.' + scope.$index + '.measuringUnit'"
  171. >
  172. <el-input
  173. v-model="scope.row.measuringUnit"
  174. v-if="!scope.row.productCode"
  175. placeholder="请输入"
  176. ></el-input>
  177. <span v-else>{{ scope.row.measuringUnit }}</span>
  178. </el-form-item>
  179. </template>
  180. <template v-slot:remark="scope">
  181. <el-form-item
  182. style="margin-bottom: 20px"
  183. :prop="'datasource.' + scope.$index + '.remark'"
  184. >
  185. <el-input
  186. v-model="scope.row.remark"
  187. type="textarea"
  188. placeholder="请输入"
  189. ></el-input>
  190. </el-form-item>
  191. </template>
  192. <template v-slot:singlePrice="scope">
  193. <el-form-item
  194. style="margin-bottom: 20px"
  195. :prop="'datasource.' + scope.$index + '.singlePrice'"
  196. :rules="{
  197. required: true,
  198. message: '请输入正确的单价',
  199. trigger: 'change'
  200. }"
  201. >
  202. <el-popover
  203. placement="right"
  204. width="600"
  205. trigger="click"
  206. @show="getPurchaseSinglePrice(scope.row)"
  207. >
  208. <el-table :data="purchaseSinglePriceData">
  209. <el-table-column
  210. width="300"
  211. property="supplierName"
  212. label="供应商"
  213. ></el-table-column>
  214. <el-table-column
  215. width="160"
  216. property="purchaseDate"
  217. label=" 采购日期"
  218. ></el-table-column>
  219. <el-table-column
  220. property="singlePrice"
  221. label="采购价格"
  222. ></el-table-column>
  223. </el-table>
  224. <el-input
  225. slot="reference"
  226. v-model="scope.row.singlePrice"
  227. type="number"
  228. placeholder="请输入"
  229. @input="changeCount(scope.row, scope.$index)"
  230. >
  231. <template slot="append">元</template>
  232. </el-input>
  233. </el-popover>
  234. </el-form-item>
  235. </template>
  236. <template v-slot:goodsPriceType="{ row, $index }">
  237. <el-form-item :prop="'datasource.' + $index + '.goodsPriceType'">
  238. <DictSelection
  239. dictName="商品价格类型"
  240. clearable
  241. v-model="row.goodsPriceType"
  242. :isOne="$index === 0"
  243. @change="goodsPriceTypeChange(row, $index)"
  244. >
  245. </DictSelection>
  246. </el-form-item>
  247. </template>
  248. <template v-slot:goodsLevel="{ row, $index }">
  249. <el-form-item :prop="'datasource.' + $index + '.goodsLevel'">
  250. <el-select v-model="row.goodsLevel" style="width: 100%">
  251. <el-option
  252. :label="item.label"
  253. :value="item.value"
  254. v-for="(item, index) in levelList"
  255. :key="index"
  256. ></el-option>
  257. </el-select>
  258. </el-form-item>
  259. </template>
  260. <template v-slot:singleWeight="scope">
  261. <el-form-item
  262. style="margin-bottom: 20px"
  263. :rules="{
  264. required: false,
  265. pattern: numberReg,
  266. trigger: 'change'
  267. }"
  268. :prop="'datasource.' + scope.$index + '.singleWeight'"
  269. >
  270. <el-input
  271. v-model="scope.row.singleWeight"
  272. @input="changeCount(scope.row, scope.$index)"
  273. placeholder="请输入"
  274. ></el-input>
  275. </el-form-item>
  276. </template>
  277. <template v-slot:technicalAnswerName="{ row, $index }">
  278. <el-form-item
  279. style="margin-bottom: 20px"
  280. :prop="'datasource.' + $index + '.technicalAnswerName'"
  281. >
  282. <el-input
  283. v-model="row.technicalAnswerName"
  284. placeholder="请输入"
  285. @click.native="handHead(row, $index)"
  286. ></el-input>
  287. </el-form-item>
  288. </template>
  289. <template v-slot:technicalParams="scope">
  290. <el-form-item
  291. style="margin-bottom: 20px"
  292. :prop="'datasource.' + scope.$index + '.technicalParams'"
  293. >
  294. <el-input
  295. type="textarea"
  296. v-model="scope.row.technicalParams"
  297. placeholder="请输入"
  298. ></el-input>
  299. </el-form-item>
  300. </template>
  301. <template v-slot:supplierMark="scope">
  302. <el-form-item
  303. style="margin-bottom: 20px"
  304. :prop="'datasource.' + scope.$index + '.supplierMark'"
  305. >
  306. <el-input
  307. v-model="scope.row.supplierMark"
  308. placeholder="请输入"
  309. ></el-input>
  310. </el-form-item>
  311. </template>
  312. <template v-slot:technicalDrawings="scope">
  313. <el-form-item
  314. style="margin-bottom: 20px"
  315. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  316. >
  317. <fileMain
  318. v-model="scope.row.technicalDrawings"
  319. :type="isContractId ? 'view' : ''"
  320. ></fileMain>
  321. </el-form-item>
  322. </template>
  323. <template v-slot:guaranteePeriodDeadline="scope">
  324. <el-form-item
  325. :prop="'datasource.' + scope.$index + '.guaranteePeriodDeadline'"
  326. >
  327. <el-date-picker
  328. style="width: 140px"
  329. v-model="scope.row.guaranteePeriodDeadline"
  330. type="date"
  331. placeholder="选择日期"
  332. >
  333. </el-date-picker>
  334. </el-form-item>
  335. </template>
  336. <template v-slot:deliveryDeadline="scope">
  337. <el-form-item
  338. :prop="'datasource.' + scope.$index + '.deliveryDeadline'"
  339. >
  340. <el-date-picker
  341. style="width: 140px"
  342. v-model="scope.row.deliveryDeadline"
  343. type="date"
  344. placeholder="选择日期"
  345. >
  346. </el-date-picker>
  347. </el-form-item>
  348. </template>
  349. <template v-slot:provenance="scope">
  350. <el-form-item :prop="'datasource.' + scope.$index + '.provenance'">
  351. <DictSelection
  352. dictName="产地"
  353. clearable
  354. v-model="scope.row.provenance"
  355. multiple
  356. :isOne="scope.$index === 0"
  357. >
  358. </DictSelection>
  359. </el-form-item>
  360. </template>
  361. <template v-slot:modelKey="scope">
  362. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'modelKey'">
  363. <DictSelection
  364. dictName="物品机型"
  365. clearable
  366. v-model="scope.row.modelKey"
  367. :isOne="scope.$index === 0"
  368. multiple
  369. filterable
  370. allow-create
  371. default-first-option
  372. >
  373. </DictSelection>
  374. </el-form-item>
  375. </template>
  376. <template v-slot:colorKey="scope">
  377. <el-form-item :prop="'datasource.' + scope.$index + '.' + 'colorKey'">
  378. <DictSelection
  379. dictName="物品颜色"
  380. clearable
  381. v-model="scope.row.colorKey"
  382. :isOne="scope.$index === 0"
  383. multiple
  384. filterable
  385. allow-create
  386. default-first-option
  387. >
  388. </DictSelection>
  389. </el-form-item>
  390. </template>
  391. <template v-slot:headerDeadline="{ column }">
  392. <span class="is-required">{{ column.label }}</span>
  393. </template>
  394. <template v-slot:headerSupplierMark="{ column }">
  395. <span class="is-required">{{ column.label }}</span>
  396. </template>
  397. <template v-slot:headerProductName="{ column }">
  398. <span class="is-required">{{ column.label }}</span>
  399. </template>
  400. <template v-slot:headerTotalCount="{ column }">
  401. <span class="is-required">{{ column.label }}</span>
  402. </template>
  403. <template v-slot:headerSinglePrice="{ column }">
  404. <span class="is-required">{{ column.label }}</span>
  405. </template>
  406. <template v-slot:batchNo="scope">
  407. <el-form-item
  408. style="margin-bottom: 20px"
  409. :prop="'datasource.' + scope.$index + '.batchNo'"
  410. >
  411. <el-input
  412. v-model="scope.row.batchNo"
  413. placeholder="请输入"
  414. v-no-chinese
  415. >
  416. </el-input>
  417. </el-form-item>
  418. </template>
  419. <!-- 操作列 -->
  420. <template v-slot:action="{ row, $index }">
  421. <el-popconfirm
  422. class="ele-action"
  423. title="确定要删除吗?"
  424. @confirm="remove(row, $index)"
  425. >
  426. <template v-slot:reference>
  427. <el-link type="danger" :underline="false" icon="el-icon-delete">
  428. 删除
  429. </el-link>
  430. </template>
  431. </el-popconfirm>
  432. </template>
  433. <template v-slot:headerPricingWay="{ column }">
  434. <span class="is-required">{{ column.label }}</span>
  435. </template>
  436. <template v-slot:purchaseCount="scope">
  437. <el-form-item
  438. style="margin-bottom: 20px"
  439. :prop="'datasource.' + scope.$index + '.purchaseCount'"
  440. :rules="{
  441. required: true,
  442. message: '请输入数量',
  443. trigger: 'change'
  444. }"
  445. >
  446. <el-input
  447. v-model="scope.row.purchaseCount"
  448. placeholder="请输入"
  449. type="number"
  450. :min="0"
  451. @input="changeCount(scope.row, scope.$index)"
  452. >
  453. </el-input>
  454. </el-form-item>
  455. </template>
  456. <template v-slot:purchaseUnit="scope">
  457. <el-form-item
  458. style="margin-bottom: 20px"
  459. :prop="'datasource.' + scope.$index + '.purchaseUnitId'"
  460. >
  461. <el-select
  462. v-model="scope.row.purchaseUnitId"
  463. style="width: 100%"
  464. @change="changeCount(scope.row, scope.$index)"
  465. >
  466. <el-option
  467. :label="item.conversionUnit"
  468. :value="item.id"
  469. @click.native="packingChange(item, scope.$index)"
  470. v-for="(item, index) in scope.row.packageDispositionList"
  471. :key="index"
  472. ></el-option>
  473. </el-select>
  474. </el-form-item>
  475. </template>
  476. </ele-pro-table>
  477. <product-list
  478. ref="productListRef"
  479. classType="1"
  480. :isGetInventoryTotal="true"
  481. @changeParent="changeParent"
  482. ></product-list>
  483. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  484. <bill-detail-dialog
  485. :bill-detail-dialog-flag.sync="billDetailDialogFlag"
  486. v-if="billDetailDialogFlag"
  487. ref="billDetailDialogRef"
  488. ></bill-detail-dialog>
  489. <taskinstance-dialog
  490. ref="taskinstanceDialogRef"
  491. v-if="taskinstanceDialogFlag"
  492. @saveTaskInstance="saveTaskInstance"
  493. :visible.sync="taskinstanceDialogFlag"
  494. ></taskinstance-dialog>
  495. </el-form>
  496. </template>
  497. <script>
  498. import { numberReg, positiveIntegerReg } from 'ele-admin';
  499. import productList from '@/BIZComponents/product-list.vue';
  500. import dictMixins from '@/mixins/dictMixins';
  501. import fileUpload from '@/components/upload/fileUpload';
  502. import headList from '@/BIZComponents/user-select/user-select.vue';
  503. import { getFile } from '@/api/system/file';
  504. import billDetailDialog from './billDetailDialog.vue';
  505. import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
  506. import { getCode } from '@/components/addDoc/api/index.js';
  507. import { pricingWayList, lbjtList } from '@/enum/dict.js';
  508. import { getInventoryTotalAPI } from '@/api/wms';
  509. import tabMixins from '@/mixins/tableColumnsMixin';
  510. import { levelList } from '@/enum/dict.js';
  511. import { getGoodsPriceByCondition } from '@/api/goodsManage/index';
  512. import { changeCount, getAllPrice } from '@/BIZComponents/setProduct.js';
  513. import { queryHistoricalUnitPrice } from '@/api/purchasingManage/purchaseOrder';
  514. const dayjs = require('dayjs');
  515. export default {
  516. mixins: [dictMixins, tabMixins],
  517. props: {
  518. isContractId: {
  519. type: Boolean,
  520. default: false
  521. },
  522. pricingWay: {
  523. type: [Number, String],
  524. default: 1
  525. },
  526. supplierMark: {
  527. type: [Number, String],
  528. default: ''
  529. },
  530. detailType: {
  531. default: 0
  532. },
  533. cacheKeyUrl:{
  534. default: 'eos-purchasingManage-purchaseOrder-inventoryTable'
  535. }
  536. },
  537. components: {
  538. taskinstanceDialog,
  539. // fileMain,
  540. productList,
  541. fileUpload,
  542. billDetailDialog,
  543. headList
  544. },
  545. computed: {
  546. canHandl() {
  547. return this.form.datasource.length;
  548. },
  549. contractId() {
  550. return this.$store.state.order.contractId;
  551. }
  552. },
  553. data() {
  554. const defaultForm = {
  555. key: null,
  556. endTime: '',
  557. isFirst: 0,
  558. name: '',
  559. startTime: '',
  560. workHour: '',
  561. technicalDrawings: []
  562. };
  563. return {
  564. levelList,
  565. pricingWayList,
  566. discountTotalPrice: 0.0,
  567. allPrice: 0.0,
  568. numberReg,
  569. positiveIntegerReg,
  570. defaultForm,
  571. contractStartDate: new Date(),
  572. form: {
  573. datasource: []
  574. },
  575. rules: {},
  576. dictList: {},
  577. billDetailDialogFlag: false,
  578. taskinstanceDialogFlag: false,
  579. columns: [
  580. {
  581. width: 45,
  582. type: 'index',
  583. columnKey: 'index',
  584. align: 'center',
  585. fixed: 'left'
  586. },
  587. {
  588. width: 200,
  589. prop: 'productName',
  590. label: '名称',
  591. slot: 'productName',
  592. headerSlot: 'headerProductName',
  593. align: 'center',
  594. fixed: 'left'
  595. },
  596. {
  597. width: 120,
  598. prop: 'productCode',
  599. label: '编码',
  600. slot: 'productCode',
  601. align: 'center'
  602. },
  603. {
  604. width: 120,
  605. prop: 'requirementTotalCount',
  606. label: '采购需求数量',
  607. slot: 'requirementTotalCount',
  608. align: 'center'
  609. },
  610. {
  611. width: 120,
  612. prop: 'planTotalCount',
  613. label: '采购计划数量',
  614. slot: 'planTotalCount',
  615. align: 'center'
  616. },
  617. {
  618. width: 120,
  619. prop: 'inquiryTotalCount',
  620. label: '采购核价数量',
  621. slot: 'inquiryTotalCount',
  622. align: 'center'
  623. },
  624. {
  625. width: 120,
  626. prop: 'contractTotalCount',
  627. label: '采购合同数量',
  628. slot: 'contractTotalCount',
  629. align: 'center'
  630. },
  631. {
  632. width: 80,
  633. prop: 'doneTotalCount',
  634. label: '已采数量',
  635. slot: 'doneTotalCount',
  636. align: 'center'
  637. },
  638. {
  639. width: 80,
  640. prop: 'waitTotalCount',
  641. label: '待采数量',
  642. // slot: 'waitTotalCount',
  643. align: 'center'
  644. },
  645. {
  646. width: 150,
  647. prop: 'purchaseCount',
  648. label: '数量',
  649. slot: 'purchaseCount',
  650. headerSlot: 'headerTotalCount',
  651. align: 'center'
  652. },
  653. {
  654. width: 150,
  655. prop: 'purchaseUnit',
  656. label: '单位',
  657. slot: 'purchaseUnit',
  658. align: 'center'
  659. },
  660. {
  661. width: 120,
  662. prop: 'packingSpecification',
  663. align: 'center',
  664. label: '包装规格',
  665. showOverflowTooltip: true
  666. },
  667. {
  668. width: 150,
  669. prop: 'totalCount',
  670. label: '计量数量',
  671. // slot: 'totalCount',
  672. // headerSlot: 'headerTotalCount',
  673. align: 'center'
  674. },
  675. {
  676. width: 80,
  677. prop: 'measuringUnit',
  678. label: '计量单位',
  679. slot: 'measuringUnit',
  680. align: 'center'
  681. },
  682. {
  683. width: 120,
  684. prop: 'availableCountBase',
  685. label: '库存数量',
  686. slot: 'availableCountBase',
  687. align: 'center'
  688. },
  689. // {
  690. // width: 160,
  691. // prop: 'pricingWay',
  692. // label: '计价方式',
  693. // headerSlot: 'headerPricingWay',
  694. // slot: 'pricingWay',
  695. // align: 'center'
  696. // },
  697. {
  698. minWidth: 120,
  699. prop: 'goodsLevel',
  700. label: '物品级别',
  701. slot: 'goodsLevel',
  702. align: 'center'
  703. },
  704. {
  705. width: 160,
  706. prop: 'goodsPriceType',
  707. label: '价格类型',
  708. slot: 'goodsPriceType',
  709. align: 'center'
  710. },
  711. !this.detailType
  712. ? {
  713. width: 160,
  714. prop: 'singlePrice',
  715. label: '单价(含税)',
  716. slot: 'singlePrice',
  717. headerSlot: 'headerSinglePrice',
  718. align: 'center'
  719. }
  720. : {
  721. width: 1
  722. },
  723. !this.detailType
  724. ? {
  725. width: 180,
  726. prop: 'notaxSinglePrice',
  727. label: '不含税单价',
  728. slot: 'notaxSinglePrice',
  729. align: 'center'
  730. }
  731. : {
  732. width: 1
  733. },
  734. !this.detailType
  735. ? {
  736. width: 150,
  737. prop: 'taxRate',
  738. label: '税率',
  739. slot: 'taxRate',
  740. align: 'center'
  741. }
  742. : {
  743. width: 1
  744. },
  745. {
  746. width: 120,
  747. prop: 'supplierMark',
  748. label: '供应商代号',
  749. // headerSlot: 'headerSupplierMark',
  750. slot: 'supplierMark',
  751. align: 'center'
  752. },
  753. {
  754. width: 200,
  755. prop: 'productCategoryName',
  756. label: '类型',
  757. slot: 'productCategoryName',
  758. showOverflowTooltip: true,
  759. align: 'center'
  760. },
  761. {
  762. minWidth: 240,
  763. prop: 'taskName',
  764. label: '工序',
  765. slot: 'taskName',
  766. align: 'center'
  767. },
  768. {
  769. width: 160,
  770. prop: 'productBrand',
  771. label: '牌号',
  772. slot: 'productBrand',
  773. showOverflowTooltip: true,
  774. align: 'center'
  775. },
  776. {
  777. width: 120,
  778. prop: 'modelType',
  779. label: '型号',
  780. slot: 'modelType',
  781. align: 'center'
  782. },
  783. {
  784. width: 160,
  785. prop: 'specification',
  786. label: '规格',
  787. slot: 'specification',
  788. align: 'center'
  789. },
  790. {
  791. width: 120,
  792. prop: 'imgCode',
  793. align: 'center',
  794. label: '图号/件号',
  795. showOverflowTooltip: true
  796. },
  797. {
  798. width: 120,
  799. prop: 'produceType',
  800. align: 'center',
  801. label: '属性类型',
  802. showOverflowTooltip: true,
  803. formatter: (row, column) => {
  804. if (row.produceType) {
  805. return row.produceType
  806. .map((item) => {
  807. return lbjtList[item];
  808. })
  809. .toString();
  810. }
  811. }
  812. },
  813. {
  814. width: 120,
  815. prop: 'singleWeight',
  816. label: '单重',
  817. slot: 'singleWeight',
  818. align: 'center'
  819. },
  820. {
  821. width: 120,
  822. prop: 'totalWeight',
  823. label: '总重',
  824. slot: 'totalWeight',
  825. align: 'center'
  826. },
  827. {
  828. width: 120,
  829. prop: 'weightUnit',
  830. label: '重量单位',
  831. slot: 'weightUnit',
  832. align: 'center'
  833. },
  834. !this.detailType
  835. ? {
  836. width: 160,
  837. prop: 'discountSinglePrice',
  838. label: '折后单价(含税)',
  839. slot: 'discountSinglePrice',
  840. align: 'center'
  841. }
  842. : {
  843. width: 1
  844. },
  845. !this.detailType
  846. ? {
  847. width: 120,
  848. prop: 'totalPrice',
  849. label: '合计(含税)',
  850. slot: 'totalPrice',
  851. align: 'center'
  852. }
  853. : {
  854. width: 1
  855. },
  856. !this.detailType
  857. ? {
  858. width: 120,
  859. prop: 'discountTotalPrice',
  860. label: '折后合计(含税)',
  861. slot: 'discountTotalPrice',
  862. align: 'center'
  863. }
  864. : {
  865. width: 1
  866. },
  867. {
  868. width: 110,
  869. prop: 'batchNo',
  870. label: '批次号',
  871. slot: 'batchNo',
  872. align: 'center'
  873. },
  874. {
  875. prop: 'provenance',
  876. label: '产地',
  877. slot: 'provenance',
  878. align: 'center',
  879. showOverflowTooltip: true,
  880. minWidth: 200
  881. },
  882. {
  883. width: 160,
  884. prop: 'modelKey',
  885. label: '机型',
  886. slot: 'modelKey',
  887. align: 'center'
  888. },
  889. {
  890. width: 160,
  891. prop: 'colorKey',
  892. label: '颜色',
  893. slot: 'colorKey',
  894. align: 'center'
  895. },
  896. {
  897. width: 160,
  898. prop: 'deliveryDeadline',
  899. label: '交期截止日期',
  900. slot: 'deliveryDeadline',
  901. align: 'center'
  902. // headerSlot: 'headerDeadline'
  903. },
  904. {
  905. width: 200,
  906. prop: 'guaranteePeriod',
  907. label: '有效期',
  908. slot: 'guaranteePeriod',
  909. align: 'center'
  910. },
  911. {
  912. width: 160,
  913. prop: 'guaranteePeriodDeadline',
  914. label: '有效期截止日期',
  915. slot: 'guaranteePeriodDeadline',
  916. align: 'center'
  917. },
  918. // {
  919. // width: 120,
  920. // prop: 'guaranteePeriodUnitCode',
  921. // label: '',
  922. // slot: 'guaranteePeriodUnitCode'
  923. // },
  924. {
  925. width: 130,
  926. prop: 'technicalAnswerName',
  927. label: '技术答疑人',
  928. slot: 'technicalAnswerName',
  929. align: 'center'
  930. },
  931. {
  932. width: 220,
  933. prop: 'technicalParams',
  934. label: '技术参数',
  935. slot: 'technicalParams',
  936. align: 'center'
  937. },
  938. {
  939. width: 240,
  940. prop: 'technicalDrawings',
  941. label: '技术图纸',
  942. slot: 'technicalDrawings',
  943. align: 'center'
  944. },
  945. {
  946. width: 220,
  947. prop: 'remark',
  948. label: '备注',
  949. slot: 'remark',
  950. align: 'center'
  951. },
  952. {
  953. columnKey: 'action',
  954. label: '操作',
  955. width: 120,
  956. align: 'center',
  957. resizable: false,
  958. slot: 'action',
  959. fixed: 'right',
  960. showOverflowTooltip: true
  961. }
  962. ],
  963. purchaseSinglePriceData: []
  964. };
  965. },
  966. created() {
  967. this.requestDict('生产类型');
  968. this.requestDict('商品价格类型');
  969. },
  970. methods: {
  971. async getPurchaseSinglePrice(row) {
  972. this.purchaseSinglePriceData = [];
  973. this.purchaseSinglePriceData = await queryHistoricalUnitPrice(
  974. row.productId
  975. );
  976. },
  977. handleGetBillDetail(row, type) {
  978. this.billDetailDialogFlag = true;
  979. this.$nextTick(() => {
  980. this.$refs.billDetailDialogRef.open(row, type);
  981. });
  982. },
  983. downloadFile(file) {
  984. getFile({ objectName: file.storePath }, file.name);
  985. },
  986. // 返回列表数据
  987. getTableValue() {
  988. let comitDatasource = this.form.datasource;
  989. if (comitDatasource.length === 0) return [];
  990. comitDatasource.forEach((v, i) => {
  991. v.detailType = this.detailType;
  992. if (v.modelKey) {
  993. v.modelKey = v.modelKey.toString();
  994. }
  995. if (v.colorKey) {
  996. v.colorKey = v.colorKey.toString();
  997. }
  998. v.guaranteePeriodUnitName = this.getDictValue(
  999. '质保期单位',
  1000. v.guaranteePeriodUnitCode
  1001. );
  1002. v.technicalDrawings = Array.isArray(v.technicalDrawings)
  1003. ? v.technicalDrawings
  1004. : [];
  1005. });
  1006. return comitDatasource;
  1007. },
  1008. getPrice() {
  1009. return [this.allPrice];
  1010. },
  1011. packingChange(item, index) {
  1012. this.$set(
  1013. this.form.datasource[index],
  1014. 'purchaseUnit',
  1015. item.conversionUnit
  1016. );
  1017. },
  1018. //改变数量
  1019. changeCount(row, index) {
  1020. // if (this.detailType) {
  1021. // return;
  1022. // }
  1023. let countObj = {
  1024. countKey: 'purchaseCount',
  1025. unitKey: 'purchaseUnit',
  1026. unitIdKey: 'purchaseUnitId'
  1027. };
  1028. if (!row) {
  1029. this.form.datasource.forEach((item, index) => {
  1030. this.$set(
  1031. this.form,
  1032. 'datasource[' + index + ']',
  1033. changeCount(item, countObj)
  1034. );
  1035. });
  1036. } else {
  1037. this.$set(
  1038. this.form,
  1039. 'datasource[' + index + ']',
  1040. changeCount(row, countObj)
  1041. );
  1042. }
  1043. this.getNotaxSinglePrice();
  1044. this.changeAll();
  1045. this.$forceUpdate();
  1046. },
  1047. changeAll() {
  1048. this.allPrice = getAllPrice(this.form.datasource) || 0;
  1049. this.$store.commit('concact/setDiscountAmount', this.allPrice);
  1050. this.$store.commit('order/setAllcountAmount', this.allPrice);
  1051. this.$emit('orderDiscountAmount', this.allPrice);
  1052. },
  1053. // //改变数量
  1054. // changeCount(row, index) {
  1055. // if (this.detailType) {
  1056. // return;
  1057. // }
  1058. // this.singleWeightChange(row, index);
  1059. // this.getTotalPrice();
  1060. // },
  1061. goodsPriceTypeChange(row, index) {
  1062. if (row.goodsId) {
  1063. getGoodsPriceByCondition({
  1064. id: row.goodsId,
  1065. priceType: row.goodsPriceType
  1066. }).then((res) => {
  1067. if (res.id) {
  1068. this.$set(this.form.datasource[index], 'goodsPriceId', res.id);
  1069. this.$set(
  1070. this.form.datasource[index],
  1071. 'goodsPriceType',
  1072. res.priceType
  1073. );
  1074. this.$set(
  1075. this.form.datasource[index],
  1076. 'singlePrice',
  1077. res.unitPrice
  1078. );
  1079. this.$set(
  1080. this.form.datasource[index],
  1081. 'notaxSinglePrice',
  1082. res.excludeTaxPrice
  1083. );
  1084. this.$set(this.form.datasource[index], 'taxRate', res.taxRate);
  1085. this.$set(
  1086. this.form.datasource[index],
  1087. 'discountSinglePrice',
  1088. res.unitPrice
  1089. );
  1090. }
  1091. this.changeCount();
  1092. });
  1093. }
  1094. },
  1095. // //计算总金额
  1096. // getTotalPrice(row, index) {
  1097. // this.getNotaxSinglePrice();
  1098. // if (this.form.datasource.length) {
  1099. // let sum = 0;
  1100. // sum = this.getNumTotalPrice();
  1101. // let allsum = sum.toFixed(2);
  1102. // this.allPrice = allsum;
  1103. // this.form.discountTotalPrice = allsum;
  1104. // this.$store.commit('concact/setDiscountAmount', allsum);
  1105. // this.$store.commit('order/setAllcountAmount', allsum);
  1106. // this.$emit('orderDiscountAmount', this.allPrice);
  1107. // this.$refs.table.reload();
  1108. // return allsum;
  1109. // } else {
  1110. // this.allPrice = 0.0;
  1111. // this.form.discountTotalPrice = 0.0;
  1112. // this.$emit('orderDiscountAmount', 0);
  1113. // return 0.0;
  1114. // }
  1115. // },
  1116. //计算不含税单价
  1117. getNotaxSinglePrice() {
  1118. this.form.datasource.forEach((item, index) => {
  1119. if (item.singlePrice && item.taxRate) {
  1120. this.$set(
  1121. this.form.datasource[index],
  1122. 'notaxSinglePrice',
  1123. parseFloat(
  1124. (item.singlePrice / (1 + item.taxRate / 100)).toFixed(2)
  1125. )
  1126. );
  1127. } else {
  1128. this.$set(this.form.datasource[index], 'notaxSinglePrice', '');
  1129. }
  1130. });
  1131. },
  1132. // //计算总金额
  1133. // getNumTotalPrice() {
  1134. // console.log(111);
  1135. // let sum = 0;
  1136. // this.form.datasource.forEach((r) => {
  1137. // this.$set(
  1138. // r,
  1139. // 'discountSinglePrice',
  1140. // r.singlePrice ? Number(r.singlePrice) : ''
  1141. // );
  1142. // if (r.singlePrice && r.totalCount) {
  1143. // r.totalPrice = this.getAllPrice(r);
  1144. // r.discountTotalPrice = this.getDiscountTotalPrice(r);
  1145. // this.$set(r, 'totalPrice', Number(r.totalPrice));
  1146. // this.$set(r, 'discountTotalPrice', Number(r.discountTotalPrice));
  1147. // sum += Number(r.totalPrice);
  1148. // } else {
  1149. // this.$set(r, 'totalPrice', '');
  1150. // this.$set(r, 'discountTotalPrice', '');
  1151. // }
  1152. // });
  1153. // return sum;
  1154. // },
  1155. // //计算单重
  1156. // singleWeightChange(row, index) {
  1157. // if (row && row.singleWeight && row.totalCount) {
  1158. // row.totalWeight = (row.singleWeight * row.totalCount).toFixed(2) || 0;
  1159. // this.$set(
  1160. // this.form.datasource[index],
  1161. // 'totalWeight',
  1162. // row.totalWeight
  1163. // );
  1164. // }
  1165. // if (row.pricingWay == 2) {
  1166. // this.getTotalPrice(row);
  1167. // }
  1168. // },
  1169. //设置优惠后总金额修改产品单价
  1170. discountInputByOrder(val) {
  1171. this.form.discountTotalPrice = val;
  1172. //获取优惠金额和总计的差价
  1173. this.form.datasource.forEach((item, index) => {
  1174. if (val === 0) {
  1175. this.$set(this.form.datasource[index], 'discountTotalPrice', 0);
  1176. this.$set(this.form.datasource[index], 'discountSinglePrice', 0);
  1177. return;
  1178. }
  1179. if (!val) {
  1180. this.$set(
  1181. this.form.datasource[index],
  1182. 'discountTotalPrice',
  1183. item.totalPrice
  1184. );
  1185. this.$set(
  1186. this.form.datasource[index],
  1187. 'discountSinglePrice',
  1188. item.singlePrice
  1189. );
  1190. return;
  1191. }
  1192. this.$set(
  1193. this.form.datasource[index],
  1194. 'discountSinglePrice',
  1195. this.getDiscountSinglePrice(item)
  1196. );
  1197. //获取折让单价
  1198. this.$set(
  1199. this.form.datasource[index],
  1200. 'discountTotalPrice',
  1201. this.getDiscountTotalPrice(item)
  1202. );
  1203. });
  1204. this.$forceUpdate();
  1205. this.$refs.table.reRenderTable();
  1206. this.$store.commit('concact/setDiscountAmount', val);
  1207. },
  1208. //获取折让单价
  1209. getDiscountSinglePrice(row) {
  1210. let num =
  1211. (Number(this.form.discountTotalPrice) / Number(this.allPrice)) *
  1212. Number(row.singlePrice);
  1213. return isNaN(num) ? '' : num.toFixed(2);
  1214. },
  1215. handleTaskinstance(row, index) {
  1216. this.taskinstanceDialogFlag = true;
  1217. this.$nextTick(() => {
  1218. this.$refs.taskinstanceDialogRef.open(row, index);
  1219. });
  1220. },
  1221. saveTaskInstance(row = {}) {
  1222. this.$set(this.form.datasource[row.index], 'taskId', row.id);
  1223. this.$set(this.form.datasource[row.index], 'taskName', row.name);
  1224. this.$set(
  1225. this.form.datasource[row.index],
  1226. 'routingId',
  1227. row.produceRoutingId
  1228. );
  1229. },
  1230. // //获取合计
  1231. // getAllPrice(row) {
  1232. // let num = 0;
  1233. // if (row.pricingWay == 1) {
  1234. // num = Number(row.singlePrice) * Number(row.totalCount);
  1235. // }
  1236. // if (row.pricingWay == 2) {
  1237. // num =
  1238. // Number(row.singlePrice) *
  1239. // Number(row.totalCount) *
  1240. // Number(row.singleWeight);
  1241. // }
  1242. // console.log(row, 'row');
  1243. // return isNaN(num) ? '' : num.toFixed(2);
  1244. // },
  1245. //获取折让合计
  1246. getDiscountTotalPrice(row) {
  1247. let num = 0;
  1248. num = Number(row.discountSinglePrice) * Number(row.totalCount);
  1249. return isNaN(num) ? '' : num.toFixed(2);
  1250. },
  1251. //修改回显
  1252. async putTableValue(data, contractStartDate) {
  1253. if (contractStartDate) {
  1254. this.contractStartDate = contractStartDate;
  1255. }
  1256. if (data) {
  1257. data.forEach((item) => {
  1258. item.guaranteePeriodUnitCode = item.guaranteePeriodUnitCode
  1259. ? item.guaranteePeriodUnitCode + ''
  1260. : '';
  1261. if (item.modelKey) {
  1262. item.modelKey = item.modelKey.split(',');
  1263. }
  1264. if (item.colorKey) {
  1265. item.colorKey = item.colorKey.split(',');
  1266. }
  1267. });
  1268. console.log(data, 'data');
  1269. this.form.datasource = data;
  1270. this.allPrice = this.$store.state.order.allcountAmount;
  1271. let codeList = this.form.datasource
  1272. .filter((item) => item.productCode)
  1273. .map((item) => item.productCode);
  1274. //获取仓库库存
  1275. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  1276. this.form.datasource
  1277. .filter((item) => item.productCode)
  1278. .forEach((item, index) => {
  1279. let find =
  1280. inventoryTotalList.find(
  1281. (key) => key.code == item.productCode
  1282. ) || {};
  1283. this.form.datasource;
  1284. this.$set(
  1285. this.form.datasource[index],
  1286. 'availableCountBase',
  1287. find.availableCountBase
  1288. );
  1289. });
  1290. }
  1291. },
  1292. //选择产品
  1293. handParent(row, index) {
  1294. let item = {
  1295. id: row.productCode
  1296. };
  1297. this.$refs.productListRef.open(item, index);
  1298. },
  1299. //选择技术人回调
  1300. changeAnswer(obj, idx) {
  1301. this.$set(this.form.datasource[idx], 'technicalAnswerId', obj.id);
  1302. this.$set(this.form.datasource[idx], 'technicalAnswerName', obj.name);
  1303. },
  1304. handHead(row, index) {
  1305. let item = {
  1306. id: row.technicalAnswerId
  1307. };
  1308. this.$refs.headRef.open(item, index);
  1309. },
  1310. getGoodsListData(obj = []) {
  1311. obj.forEach((item) => {
  1312. this.$set(item, 'supplierMark', this.supplierMark);
  1313. this.form.datasource.push(item);
  1314. });
  1315. },
  1316. setCustomerMark(supplierMark) {
  1317. console.log(supplierMark);
  1318. this.form.datasource.forEach((item, index) => {
  1319. this.$set(this.form.datasource[index], 'supplierMark', supplierMark);
  1320. console.log(
  1321. this.form.datasource[index],
  1322. 'this.form.datasource[index]'
  1323. );
  1324. });
  1325. },
  1326. //选择产品回调
  1327. changeParent(obj = [], idx) {
  1328. obj.forEach(async (item, index) => {
  1329. let i = idx == -1 ? index : idx;
  1330. let row = JSON.parse(JSON.stringify(this.defaultForm));
  1331. row.key = this.form.datasource.length + 1;
  1332. let parasm = idx == -1 ? row : this.form.datasource[i];
  1333. this.$set(parasm, 'productId', item.id);
  1334. this.$set(parasm, 'categoryName', item.name);
  1335. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  1336. this.$set(parasm, 'productBrand', item.brandNum);
  1337. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  1338. this.$set(parasm, 'productCode', item.code);
  1339. this.$set(parasm, 'productName', item.name);
  1340. this.$set(parasm, 'modelType', item.modelType);
  1341. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  1342. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  1343. this.$set(parasm, 'specification', item.specification);
  1344. this.$set(parasm, 'weightUnit', item.weightUnit);
  1345. this.$set(parasm, 'imgCode', item.imgCode);
  1346. this.$set(parasm, 'produceType', item.componentAttribute);
  1347. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  1348. this.$set(parasm, 'singleWeight', item.netWeight);
  1349. this.$set(parasm, 'pricingWay', item.pricingWay || 1);
  1350. this.$set(parasm, 'goodsLevel', item.level);
  1351. this.$set(parasm, 'taxRate', 13);
  1352. this.$set(parasm, 'totalCount', 0);
  1353. if (item.modelKey) {
  1354. this.$set(parasm, 'modelKey', item.modelKey.split(','));
  1355. }
  1356. if (item.colorKey) {
  1357. this.$set(parasm, 'colorKey', item.colorKey.split(','));
  1358. }
  1359. this.$set(
  1360. parasm,
  1361. 'packingSpecification',
  1362. item.extField?.packingSpecification
  1363. );
  1364. this.$set(
  1365. parasm,
  1366. 'packageDispositionList',
  1367. item.packageDispositionList
  1368. );
  1369. if (item.packageDispositionList?.length) {
  1370. this.$set(
  1371. parasm,
  1372. 'purchaseUnitId',
  1373. item.packageDispositionList[0].id
  1374. );
  1375. this.$set(
  1376. parasm,
  1377. 'purchaseUnit',
  1378. item.packageDispositionList[0].conversionUnit
  1379. );
  1380. }
  1381. this.$set(parasm, 'supplierMark', this.supplierMark);
  1382. // this.$set(parasm, 'batchNo', await getCode('1900101420390125570'));
  1383. if (item.purchaseOrigins?.length > 0) {
  1384. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  1385. }
  1386. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  1387. if (idx == -1) {
  1388. this.form.datasource.push(row);
  1389. }
  1390. });
  1391. },
  1392. remove(row, index) {
  1393. this.form.datasource.splice(index, 1);
  1394. // let index = this.form.datasource.findIndex((n) => n.key == row.key);
  1395. // if (index !== -1) {
  1396. // this.form.datasource.splice(index, 1);
  1397. // this.setSort();
  1398. // }
  1399. },
  1400. // 清空表格
  1401. restTable() {
  1402. this.form.datasource = [];
  1403. },
  1404. // 重新排序
  1405. setSort() {
  1406. this.form.datasource.forEach((n, index) => {
  1407. n.key = index + 1;
  1408. });
  1409. },
  1410. // 添加
  1411. handlAdd() {
  1412. let item = JSON.parse(JSON.stringify(this.defaultForm));
  1413. item.key = this.form.datasource.length + 1;
  1414. this.form.datasource.push(item);
  1415. },
  1416. setDeliveryDays(row, index, type) {
  1417. if (type == 'deliveryDays') {
  1418. this.$set(
  1419. this.form.datasource[index],
  1420. 'deliveryDeadline',
  1421. this.setDay(row.deliveryDays)
  1422. );
  1423. }
  1424. if (type == 'guaranteePeriod') {
  1425. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  1426. row.guaranteePeriodUnitCode
  1427. );
  1428. this.$set(
  1429. this.form.datasource[index],
  1430. 'guaranteePeriodDeadline',
  1431. guaranteePeriodUnitName != 'second'
  1432. ? this.setDay(row.guaranteePeriod, guaranteePeriodUnitName)
  1433. : ''
  1434. );
  1435. }
  1436. },
  1437. guaranteePeriodUnit(code) {
  1438. return code == 3
  1439. ? 'day'
  1440. : code == 4
  1441. ? 'month'
  1442. : code == 5
  1443. ? 'year'
  1444. : 'second';
  1445. },
  1446. setDay(addDay, dateType = 'day') {
  1447. return dayjs(this.contractStartDate || new Date())
  1448. .add(addDay, dateType)
  1449. .format('YYYY-MM-DD');
  1450. },
  1451. validateForm(callback) {
  1452. let singleWeightData = {};
  1453. this.form.datasource.forEach((item) => {
  1454. if (item.pricingWay == 2 && !item.singleWeight) {
  1455. singleWeightData['name'] = item.productName;
  1456. }
  1457. });
  1458. if (singleWeightData.name) {
  1459. this.$message.warning(
  1460. singleWeightData.name + '计价方式为重量,单重不能为空'
  1461. );
  1462. callback(false);
  1463. }
  1464. //开始表单校验
  1465. this.$refs.form.validate((valid) => {
  1466. callback(valid);
  1467. });
  1468. }
  1469. }
  1470. };
  1471. </script>
  1472. <style lang="scss" scoped>
  1473. .headbox {
  1474. display: flex;
  1475. justify-content: space-between;
  1476. align-items: center;
  1477. .amount {
  1478. font-size: 14px;
  1479. font-weight: bold;
  1480. padding-right: 30px;
  1481. }
  1482. }
  1483. .time-form .el-form-item {
  1484. margin-bottom: 0 !important;
  1485. }
  1486. ::v-deep .period {
  1487. display: flex;
  1488. .borderleftnone {
  1489. .el-input--medium .el-input__inner {
  1490. border-top-right-radius: 0;
  1491. border-bottom-right-radius: 0;
  1492. }
  1493. }
  1494. .borderrightnone {
  1495. .el-input--medium .el-input__inner {
  1496. border-top-left-radius: 0;
  1497. border-bottom-left-radius: 0;
  1498. }
  1499. }
  1500. }
  1501. ::v-deep .time-form tbody > tr:hover > td {
  1502. background-color: transparent !important;
  1503. }
  1504. ::v-deep .time-form .el-table tr {
  1505. background-color: #ffffff;
  1506. }
  1507. .pricebox {
  1508. display: flex;
  1509. justify-content: flex-start;
  1510. align-items: center;
  1511. font-weight: bold;
  1512. }
  1513. </style>