inventoryTable.vue 46 KB

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