inventoryTable.vue 49 KB

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