inventoryTable.vue 41 KB

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