inventoryTable.vue 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011
  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. :datasource="form.datasource"
  8. class="time-form"
  9. max-height="300"
  10. @columns-change="handleColumnChange"
  11. :cache-key="cacheKeyUrl"
  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. >
  24. 新增
  25. </el-button>
  26. <el-button
  27. size="small"
  28. type="primary"
  29. icon="el-icon-plus"
  30. class="ele-btn-icon"
  31. v-if="isGoods"
  32. @click="handGoods(-1)"
  33. >
  34. 选择商品
  35. </el-button>
  36. <el-button
  37. size="small"
  38. type="primary"
  39. icon="el-icon-plus"
  40. class="ele-btn-icon"
  41. v-if="isTemporary"
  42. @click="handlAdd"
  43. >
  44. 新增临时产品
  45. </el-button>
  46. <el-button
  47. size="small"
  48. type="primary"
  49. class="ele-btn-icon"
  50. @click="save"
  51. v-if="isDrawer"
  52. >
  53. 保存
  54. </el-button>
  55. </div>
  56. <div class="pricebox">
  57. <span class="amount">总计:{{ allPrice }}元</span>
  58. <el-form-item
  59. style="width: 300px"
  60. v-if="isDiscountTotalPrice"
  61. label="优惠后总金额:"
  62. prop="discountTotalPrice"
  63. :rules="{
  64. required: true,
  65. message: '请输入优惠后总金额',
  66. trigger: 'change'
  67. }"
  68. >
  69. <el-input
  70. type="number"
  71. :min="0"
  72. :max="allPrice"
  73. :disabled="!allPrice"
  74. v-model="form.discountTotalPrice"
  75. style="width: 180px"
  76. placeholder="请输入"
  77. @input="discountInputByOrder(form.discountTotalPrice)"
  78. >
  79. <template slot="append">元</template>
  80. </el-input>
  81. </el-form-item>
  82. </div>
  83. </div>
  84. </template>
  85. <template v-slot:productName="{ row, $index }">
  86. <el-form-item
  87. style="margin-bottom: 20px"
  88. :prop="'datasource.' + $index + '.productName'"
  89. :rules="{
  90. required: true,
  91. message: '请输入',
  92. trigger: 'change'
  93. }"
  94. >
  95. <el-input
  96. :disabled="!!row.productCode"
  97. v-model="row.productName"
  98. placeholder="请输入"
  99. style="width: 60%; margin-right: 10px"
  100. ></el-input>
  101. <el-button
  102. size="small"
  103. type="primary"
  104. @click.native="handParent(row, $index)"
  105. >选择
  106. </el-button>
  107. </el-form-item>
  108. </template>
  109. <template v-slot:entrustedEnterpriseId="scope">
  110. <el-form-item prop="entrustedEnterpriseId">
  111. <el-select
  112. v-model="scope.row['entrustedEnterpriseId']"
  113. clearable
  114. filterable
  115. >
  116. <el-option
  117. v-for="i in scope.row.entrustedEnterpriseIdList"
  118. :key="i.id"
  119. :value="i.id"
  120. :label="i.name"
  121. ></el-option>
  122. </el-select>
  123. </el-form-item>
  124. </template>
  125. <template v-slot:headerCustomerMark="{ column }">
  126. <span :class="isCustomerMark ? 'is-required' : ''">{{
  127. column.label
  128. }}</span>
  129. </template>
  130. <template v-slot:customerMark="{ row, $index }">
  131. <el-form-item
  132. :prop="'datasource.' + $index + '.customerMark'"
  133. :rules="{
  134. required: isCustomerMark ? true : false,
  135. message: '请输入客户代号',
  136. trigger: 'change'
  137. }"
  138. >
  139. <el-input v-model="row.customerMark" placeholder="请输入"></el-input>
  140. </el-form-item>
  141. </template>
  142. <!-- <template v-slot:headerSupplierMark="{ column }">
  143. <span :class="isSupplierMark ? 'is-required' : ''">{{
  144. column.label
  145. }}</span>
  146. </template>
  147. <template v-slot:supplierMark="{ row, $index }">
  148. <el-form-item
  149. :prop="'datasource.' + $index + '.supplierMark'"
  150. :rules="{
  151. required: isSupplierMark ? true : false,
  152. message: '请输入',
  153. trigger: 'change'
  154. }"
  155. >
  156. <el-input v-model="row.supplierMark" placeholder="请输入"></el-input>
  157. </el-form-item>
  158. </template> -->
  159. <template v-slot:headerProductName="{ column }">
  160. <span class="is-required">{{ column.label }}</span>
  161. </template>
  162. <template v-slot:productCode="scope">
  163. <el-form-item
  164. style="margin-bottom: 20px"
  165. :prop="'datasource.' + scope.$index + '.productCode'"
  166. >
  167. <el-input v-model="scope.row.productCode" :disabled="true"></el-input>
  168. </el-form-item>
  169. </template>
  170. <template v-slot:productCategoryName="scope">
  171. <el-form-item
  172. style="margin-bottom: 20px"
  173. :prop="'datasource.' + scope.$index + '.productCategoryName'"
  174. >
  175. <el-input v-model="scope.row.productCategoryName" disabled></el-input>
  176. </el-form-item>
  177. </template>
  178. <!-- <template v-slot:totalCount="scope">
  179. <el-form-item
  180. style="margin-bottom: 20px"
  181. :prop="'datasource.' + scope.$index + '.totalCount'"
  182. :rules="{
  183. required: isTotalCount ? true : false,
  184. message: '请输入数量',
  185. trigger: 'change'
  186. }"
  187. >
  188. <el-input
  189. v-model="scope.row.totalCount"
  190. type="number"
  191. placeholder="请输入"
  192. @input="changeCount(scope.row, scope.$index)"
  193. ></el-input>
  194. </el-form-item>
  195. </template> -->
  196. <template v-slot:headerTotalCount="{ column }">
  197. <span :class="{ 'is-required': isTotalCount }">{{ column.label }}</span>
  198. </template>
  199. <template v-slot:totalPrice="scope">
  200. <el-form-item
  201. style="margin-bottom: 20px"
  202. :prop="'datasource.' + scope.$index + '.totalPrice'"
  203. >
  204. {{ (Number(scope.row.totalPrice) || 0).toFixed(2) }}元
  205. </el-form-item>
  206. </template>
  207. <template v-slot:productBrand="scope">
  208. <el-form-item
  209. style="margin-bottom: 20px"
  210. :prop="'datasource.' + scope.$index + '.productBrand'"
  211. >
  212. <el-input
  213. v-model="scope.row.productBrand"
  214. :disabled="!!scope.row.productCode"
  215. ></el-input>
  216. </el-form-item>
  217. </template>
  218. <template v-slot:modelType="scope">
  219. <el-form-item
  220. style="margin-bottom: 20px"
  221. :prop="'datasource.' + scope.$index + '.modelType'"
  222. >
  223. <el-input
  224. v-model="scope.row.modelType"
  225. :disabled="!!scope.row.productCode"
  226. ></el-input>
  227. </el-form-item>
  228. </template>
  229. <template v-slot:specification="scope">
  230. <el-form-item
  231. style="margin-bottom: 20px"
  232. :prop="'datasource.' + scope.$index + '.specification'"
  233. >
  234. <el-input
  235. v-model="scope.row.specification"
  236. :disabled="!!scope.row.productCode"
  237. ></el-input>
  238. </el-form-item>
  239. </template>
  240. <template v-slot:headerGuaranteePeriod="{ column }">
  241. <span :class="{ 'is-required': contractBookType == 1 }">{{
  242. column.label
  243. }}</span>
  244. </template>
  245. <template v-slot:guaranteePeriod="scope">
  246. <div class="period">
  247. <div class="borderleftnone">
  248. <el-form-item
  249. style="margin-bottom: 20px"
  250. :prop="'datasource.' + scope.$index + '.guaranteePeriod'"
  251. :rules="{
  252. pattern: numberReg,
  253. message: '请输入有效期',
  254. trigger: 'blur'
  255. }"
  256. >
  257. <el-input
  258. v-model="scope.row.guaranteePeriod"
  259. @change="
  260. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  261. "
  262. placeholder="请输入"
  263. ></el-input>
  264. </el-form-item>
  265. </div>
  266. <div class="borderrightnone">
  267. <DictSelection
  268. dictName="质保期单位"
  269. clearable
  270. v-model="scope.row.guaranteePeriodUnitCode"
  271. @change="
  272. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  273. "
  274. >
  275. </DictSelection>
  276. </div>
  277. </div>
  278. </template>
  279. <template v-slot:measuringUnit="scope">
  280. <el-form-item
  281. style="margin-bottom: 20px"
  282. :prop="'datasource.' + scope.$index + '.measuringUnit'"
  283. >
  284. <el-input
  285. v-model="scope.row.measuringUnit"
  286. :disabled="!!scope.row.productCode"
  287. placeholder="请输入"
  288. ></el-input>
  289. </el-form-item>
  290. </template>
  291. <template v-slot:remark="scope">
  292. <el-form-item
  293. style="margin-bottom: 20px"
  294. :prop="'datasource.' + scope.$index + '.remark'"
  295. >
  296. <el-input
  297. v-model="scope.row.remark"
  298. type="textarea"
  299. placeholder="请输入"
  300. ></el-input>
  301. </el-form-item>
  302. </template>
  303. <template v-slot:singlePrice="scope">
  304. <el-form-item
  305. style="margin-bottom: 20px"
  306. :prop="'datasource.' + scope.$index + '.singlePrice'"
  307. :rules="{
  308. required: isSinglePrice ? true : false,
  309. message: '请输入单价',
  310. trigger: 'change'
  311. }"
  312. >
  313. <el-input
  314. v-model="scope.row.singlePrice"
  315. placeholder="请输入"
  316. type="number"
  317. @input="changeCount(scope.row, scope.$index)"
  318. >
  319. <template slot="append">元</template>
  320. </el-input>
  321. </el-form-item>
  322. </template>
  323. <!-- <template v-slot:notaxSinglePrice="scope">
  324. <el-form-item
  325. style="margin-bottom: 20px"
  326. :prop="'datasource.' + scope.$index + '.notaxSinglePrice'"
  327. >
  328. <el-input
  329. v-model="scope.row.notaxSinglePrice"
  330. placeholder="请输入"
  331. type="number"
  332. >
  333. <template slot="append">元</template>
  334. </el-input>
  335. </el-form-item>
  336. </template> -->
  337. <template v-slot:taxRate="scope">
  338. <el-form-item
  339. style="margin-bottom: 20px"
  340. :prop="'datasource.' + scope.$index + '.taxRate'"
  341. >
  342. <el-input
  343. v-model="scope.row.taxRate"
  344. placeholder="请输入"
  345. type="number"
  346. @input="getNotaxSinglePrice"
  347. >
  348. <template slot="append">%</template>
  349. </el-input>
  350. </el-form-item>
  351. </template>
  352. <template v-slot:headerSinglePrice="{ column }">
  353. <span :class="isSinglePrice ? 'is-required' : ''">{{
  354. column.label
  355. }}</span>
  356. </template>
  357. <template v-slot:headerCustomerExpectDeliveryDeadline="{ column }">
  358. <span class="is-required">{{ column.label }}</span>
  359. </template>
  360. <template v-slot:technicalAnswerName="{ row, $index }">
  361. <el-form-item
  362. style="margin-bottom: 20px"
  363. :prop="'datasource.' + $index + '.technicalAnswerName'"
  364. >
  365. <el-input
  366. v-model="row.technicalAnswerName"
  367. placeholder="请输入"
  368. @click.native="handHead(row, $index)"
  369. ></el-input>
  370. </el-form-item>
  371. </template>
  372. <template v-slot:technicalParams="scope">
  373. <el-form-item
  374. style="margin-bottom: 20px"
  375. :prop="'datasource.' + scope.$index + '.technicalParams'"
  376. >
  377. <el-input
  378. type="textarea"
  379. v-model="scope.row.technicalParams"
  380. placeholder="请输入"
  381. ></el-input>
  382. </el-form-item>
  383. </template>
  384. <template v-slot:technicalDrawings="scope">
  385. <el-form-item
  386. style="margin-bottom: 20px"
  387. :prop="'datasource.' + scope.$index + '.technicalDrawings'"
  388. >
  389. <fileMain v-model="scope.row.technicalDrawings"></fileMain>
  390. </el-form-item>
  391. </template>
  392. <template v-slot:customerReqFiles="scope">
  393. <el-form-item
  394. style="margin-bottom: 20px"
  395. :prop="'datasource.' + scope.$index + '.customerReqFiles'"
  396. >
  397. <fileMain v-model="scope.row.customerReqFiles"></fileMain>
  398. </el-form-item>
  399. </template>
  400. <template v-slot:industryArtFiles="scope">
  401. <el-form-item
  402. style="margin-bottom: 20px"
  403. :prop="'datasource.' + scope.$index + '.industryArtFiles'"
  404. :rules="{
  405. required: false,
  406. message: '请输入',
  407. trigger: 'change'
  408. }"
  409. >
  410. <fileMain v-model="scope.row.industryArtFiles"></fileMain>
  411. </el-form-item>
  412. </template>
  413. <template v-slot:otherFiles="scope">
  414. <el-form-item
  415. style="margin-bottom: 20px"
  416. :prop="'datasource.' + scope.$index + '. otherFiles'"
  417. >
  418. <fileMain v-model="scope.row.otherFiles"></fileMain>
  419. </el-form-item>
  420. </template>
  421. <template v-slot:headerProduceDeliveryDeadline="{ column }">
  422. <span :class="isProduceDeliveryDeadline ? 'is-required' : ''">{{
  423. column.label
  424. }}</span>
  425. </template>
  426. <template v-slot:produceDeliveryDeadline="scope">
  427. <el-form-item
  428. :prop="'datasource.' + scope.$index + '.produceDeliveryDeadline'"
  429. :rules="{
  430. required: isProduceDeliveryDeadline ? true : false,
  431. message: '选择生产交付交期',
  432. trigger: 'change'
  433. }"
  434. >
  435. <el-date-picker
  436. style="width: 140px"
  437. v-model="scope.row.produceDeliveryDeadline"
  438. @change="
  439. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  440. "
  441. type="date"
  442. placeholder="选择日期"
  443. >
  444. </el-date-picker>
  445. </el-form-item>
  446. </template>
  447. <template v-slot:customerExpectDeliveryDeadline="scope">
  448. <el-form-item
  449. v-if="scope.row.arrivalWay == 1"
  450. :rules="{
  451. required: true,
  452. message:
  453. contractBookType == 1 ? '请选择客户期望交期' : '请选择交付日期',
  454. trigger: 'change'
  455. }"
  456. :prop="
  457. 'datasource.' + scope.$index + '.customerExpectDeliveryDeadline'
  458. "
  459. >
  460. <el-date-picker
  461. style="width: 140px"
  462. v-model="scope.row.customerExpectDeliveryDeadline"
  463. @change="
  464. setDeliveryDays(scope.row, scope.$index, 'guaranteePeriod')
  465. "
  466. type="date"
  467. placeholder="选择日期"
  468. >
  469. </el-date-picker>
  470. </el-form-item>
  471. <el-form-item
  472. style="margin-bottom: 20px"
  473. v-if="scope.row.arrivalWay == 2"
  474. >
  475. <el-link
  476. type="primary"
  477. :underline="false"
  478. @click.native="handleMethod(scope.row, scope.$index)"
  479. >
  480. 设置分批时间
  481. </el-link>
  482. </el-form-item>
  483. </template>
  484. <template v-slot:provenance="scope">
  485. <el-form-item :prop="'datasource.' + scope.$index + '.provenance'">
  486. <DictSelection
  487. dictName="产地"
  488. clearable
  489. v-model="scope.row.provenance"
  490. collapse-tags
  491. multiple
  492. >
  493. </DictSelection>
  494. </el-form-item>
  495. </template>
  496. <template v-slot:guaranteePeriodDeadline="scope">
  497. <el-form-item
  498. :prop="'datasource.' + scope.$index + '.guaranteePeriodDeadline'"
  499. >
  500. <el-date-picker
  501. style="width: 140px"
  502. v-model="scope.row.guaranteePeriodDeadline"
  503. type="date"
  504. placeholder="选择日期"
  505. >
  506. </el-date-picker>
  507. </el-form-item>
  508. </template>
  509. <template v-slot:singleWeight="scope">
  510. <el-form-item
  511. style="margin-bottom: 20px"
  512. :prop="'datasource.' + scope.$index + '.singleWeight'"
  513. >
  514. <el-input
  515. v-model="scope.row.singleWeight"
  516. @input="changeCount(scope.row, scope.$index)"
  517. placeholder="请输入"
  518. ></el-input>
  519. </el-form-item>
  520. </template>
  521. <template v-slot:technologyRouteName="scope">
  522. <el-form-item
  523. :prop="'datasource.' + scope.$index + '.technologyRouteName'"
  524. :rules="{
  525. required: false,
  526. message: '请选择',
  527. trigger: 'change'
  528. }"
  529. >
  530. <el-input
  531. v-model="scope.row.technologyRouteName"
  532. placeholder="请选择"
  533. @click.native="openVersion(scope.$index)"
  534. ></el-input>
  535. </el-form-item>
  536. </template>
  537. <template v-slot:pricingWay="scope">
  538. <el-form-item :prop="'datasource.' + scope.$index + '.pricingWay'">
  539. <el-select
  540. v-model="scope.row.pricingWay"
  541. placeholder="请选择"
  542. :rules="{
  543. required: true,
  544. message: '请选择计价方式',
  545. trigger: 'change'
  546. }"
  547. >
  548. <el-option
  549. v-for="item in pricingWayList"
  550. :key="item.id"
  551. :label="item.name"
  552. :value="item.id"
  553. @click.native="changeCount(scope.row, scope.$index)"
  554. >
  555. </el-option>
  556. </el-select>
  557. </el-form-item>
  558. </template>
  559. <template v-slot:headerPricingWay="{ column }">
  560. <span class="is-required">{{ column.label }}</span>
  561. </template>
  562. <template v-slot:taskName="scope">
  563. <el-form-item
  564. style="margin-bottom: 20px"
  565. :prop="'datasource.' + scope.$index + '.taskName'"
  566. >
  567. <el-input
  568. v-model="scope.row.taskName"
  569. placeholder="请选择"
  570. style="width: 60%; margin-right: 10px"
  571. disabled
  572. ></el-input>
  573. <el-button
  574. v-if="scope.row.productCode"
  575. size="small"
  576. type="primary"
  577. @click.native="handleTaskinstance(scope.row, scope.$index)"
  578. >选择
  579. </el-button>
  580. </el-form-item>
  581. </template>
  582. <template v-slot:arrivalWay="scope">
  583. <el-form-item :prop="'datasource.' + scope.$index + '.arrivalWay'">
  584. <el-select
  585. v-model="scope.row.arrivalWay"
  586. clearable
  587. style="width: 100%"
  588. >
  589. <el-option
  590. v-for="item in arrivalWayList"
  591. :key="item.value"
  592. :label="item.label"
  593. :value="item.value"
  594. >
  595. </el-option>
  596. </el-select>
  597. </el-form-item>
  598. </template>
  599. <template v-slot:batchNo="scope">
  600. <el-form-item
  601. style="margin-bottom: 20px"
  602. :prop="'datasource.' + scope.$index + '.batchNo'"
  603. >
  604. <el-input
  605. v-model="scope.row.batchNo"
  606. placeholder="请输入"
  607. v-no-chinese
  608. >
  609. </el-input>
  610. </el-form-item>
  611. </template>
  612. <template v-slot:orderNo="{ row, $index }">
  613. <el-form-item :prop="'datasource.' + $index + '.orderNo'">
  614. <el-select v-model="row.orderNo" style="width: 100%">
  615. <el-option
  616. :label="item.orderNo"
  617. :value="item.orderNo"
  618. @click.native="orderNoChange(row, item)"
  619. v-for="(item, index) in orderOption"
  620. :key="index"
  621. ></el-option>
  622. </el-select>
  623. </el-form-item>
  624. </template>
  625. <template v-slot:goodsLevel="{ row, $index }">
  626. <el-form-item :prop="'datasource.' + $index + '.goodsLevel'">
  627. <el-select v-model="row.goodsLevel" style="width: 100%">
  628. <el-option
  629. :label="item.label"
  630. :value="item.value"
  631. v-for="(item, index) in levelList"
  632. :key="index"
  633. ></el-option>
  634. </el-select>
  635. </el-form-item>
  636. </template>
  637. <template v-slot:goodsPriceType="{ row, $index }">
  638. <el-form-item :prop="'datasource.' + $index + '.goodsPriceType'">
  639. <DictSelection
  640. dictName="商品价格类型"
  641. clearable
  642. v-model="row.goodsPriceType"
  643. @change="goodsPriceTypeChange(row, $index)"
  644. >
  645. </DictSelection>
  646. </el-form-item>
  647. </template>
  648. <template v-slot:saleCount="scope">
  649. <el-form-item
  650. style="margin-bottom: 20px"
  651. :prop="'datasource.' + scope.$index + '.' + countObj.countKey"
  652. :rules="{
  653. required: isTotalCount ? true : false,
  654. message: '请输入数量',
  655. trigger: 'change'
  656. }"
  657. >
  658. <el-input
  659. v-model="scope.row[countObj.countKey]"
  660. placeholder="请输入"
  661. type="number"
  662. :min="0"
  663. @input="changeCount(scope.row, scope.$index)"
  664. >
  665. </el-input>
  666. </el-form-item>
  667. </template>
  668. <template v-slot:saleUnit="scope">
  669. <el-form-item
  670. style="margin-bottom: 20px"
  671. :prop="'datasource.' + scope.$index + '.' + countObj.unitIdKey"
  672. >
  673. <el-select
  674. v-model="scope.row[countObj.unitIdKey]"
  675. style="width: 100%"
  676. @change="changeCount(scope.row, scope.$index)"
  677. >
  678. <el-option
  679. :label="item.conversionUnit"
  680. :value="item.id"
  681. @click.native="packingChange(item, scope.$index)"
  682. v-for="(item, index) in scope.row.packageDispositionList"
  683. :key="index"
  684. ></el-option>
  685. </el-select>
  686. </el-form-item>
  687. </template>
  688. <!-- 操作列 -->
  689. <template v-slot:action="scope">
  690. <el-popconfirm
  691. class="ele-action"
  692. title="确定要删除吗?"
  693. @confirm="remove(scope.$index)"
  694. >
  695. <template v-slot:reference>
  696. <el-link type="danger" :underline="false" icon="el-icon-delete">
  697. 删除
  698. </el-link>
  699. </template>
  700. </el-popconfirm>
  701. </template>
  702. </ele-pro-table>
  703. <product-list
  704. ref="productListRef"
  705. classType="1"
  706. :is-get-inventory-total="true"
  707. @changeParent="changeParent"
  708. :isSupplier="isSupplier"
  709. :isSalesRecord="isSalesRecord"
  710. ></product-list>
  711. <head-list ref="headRef" @changeParent="changeAnswer"></head-list>
  712. <ProductionVersion
  713. ref="versionRefs"
  714. @changeProduct="changeProduct"
  715. ></ProductionVersion>
  716. <taskinstance-dialog
  717. ref="taskinstanceDialogRef"
  718. v-if="taskinstanceDialogFlag"
  719. @saveTaskInstance="saveTaskInstance"
  720. :visible.sync="taskinstanceDialogFlag"
  721. ></taskinstance-dialog>
  722. <timeDialog
  723. @chooseTime="chooseTime"
  724. ref="timeDialogRef"
  725. :isBatch="true"
  726. ></timeDialog>
  727. <selectStockLedgerDialog
  728. ref="selectStockLedgerDialogRef"
  729. @changeParent="replaceTable"
  730. :isSupplier="isSupplier"
  731. ></selectStockLedgerDialog>
  732. <commodityPriceListDialog
  733. ref="commodityPriceListDialogRef"
  734. @changeParent="changeParent"
  735. ></commodityPriceListDialog>
  736. </el-form>
  737. </template>
  738. <script>
  739. import { numberReg } from 'ele-admin';
  740. import productList from '@/BIZComponents/product-list.vue';
  741. import dictMixins from '@/mixins/dictMixins';
  742. import fileUpload from '@/components/upload/fileUpload';
  743. import headList from '@/BIZComponents/user-select/user-select.vue';
  744. import ProductionVersion from '@/components/ProductionVersion2/index.vue';
  745. import { getInventoryTotalAPI } from '@/api/wms';
  746. // import fileMain from '@/components/addDoc/index.vue';
  747. import { pricingWayList, lbjtList } from '@/enum/dict.js';
  748. import { changeCount, getAllPrice } from '@/BIZComponents/setProduct.js';
  749. import { contactQueryByCategoryIdsAPI } from '@/api/saleManage/contact';
  750. import taskinstanceDialog from '@/BIZComponents/procedure/taskinstanceDialog.vue';
  751. import timeDialog from '@/components/timeDialog/index.vue';
  752. import { copyObj } from '@/utils/util';
  753. import selectStockLedgerDialog from '@/BIZComponents/selectStockLedger/selectStockLedgerDialog.vue'; //库存台账
  754. import tabMixins from '@/mixins/tableColumnsMixin';
  755. import commodityPriceListDialog from '@/views/commodityManagement/commodityPriceList/components/commodityPriceListDialog.vue';
  756. const dayjs = require('dayjs');
  757. import { levelList } from '@/enum/dict.js';
  758. import { getGoodsPriceByCondition } from '@/api/goodsManage/index';
  759. export default {
  760. mixins: [dictMixins, tabMixins],
  761. components: {
  762. // fileMain,
  763. productList,
  764. fileUpload,
  765. headList,
  766. ProductionVersion,
  767. taskinstanceDialog,
  768. timeDialog,
  769. selectStockLedgerDialog,
  770. commodityPriceListDialog
  771. },
  772. props: {
  773. pageName: {
  774. default: '',
  775. type: String
  776. },
  777. isDiscountTotalPrice: {
  778. default: false,
  779. type: Boolean
  780. },
  781. isGuaranteePeriod: {
  782. default: true,
  783. type: Boolean
  784. },
  785. customerMark: {
  786. default: '',
  787. type: String
  788. },
  789. isContractId: {
  790. type: Boolean,
  791. default: false
  792. },
  793. isSinglePrice: {
  794. //单价必填
  795. type: Boolean,
  796. default: true
  797. },
  798. isTotalCount: {
  799. //数量必填
  800. type: Boolean,
  801. default: true
  802. },
  803. isCustomerMark: {
  804. //客户代号必填
  805. type: Boolean,
  806. default: false
  807. },
  808. isDiscount: {
  809. //折让
  810. type: Boolean,
  811. default: true
  812. },
  813. isProduceDeliveryDeadline: {
  814. //生产交付交期必填
  815. type: Boolean,
  816. default: false
  817. },
  818. isDrawer: {
  819. type: Boolean,
  820. default: false
  821. },
  822. isChangeCount: {
  823. //默认计算
  824. type: Boolean,
  825. default: true
  826. },
  827. contractBookType: {
  828. //合同类型 1销售 2采购
  829. type: [String, Number],
  830. default: 1
  831. },
  832. // isSupplierMark: {
  833. // //客户代号必填
  834. // type: Boolean,
  835. // default: false
  836. // },
  837. isTemporary: {
  838. //临时
  839. type: Boolean,
  840. default: false
  841. },
  842. isSupplier: {
  843. //供应商
  844. type: Boolean,
  845. default: false
  846. },
  847. isSalesRecord: {
  848. default: ''
  849. },
  850. isArrivalWay: {
  851. //分批到货时间
  852. type: Boolean,
  853. default: false
  854. },
  855. //订单类型
  856. needProduce: {
  857. type: [String, Number],
  858. default: 1
  859. },
  860. cacheKeyUrl: '',
  861. //是否显示订单编码
  862. isOrderNo: {
  863. type: Boolean,
  864. default: false
  865. },
  866. orderOption: {
  867. default: () => {
  868. return [];
  869. }
  870. },
  871. //是否商品
  872. isGoods: {
  873. type: Boolean,
  874. default: false
  875. },
  876. countObj: {
  877. type: Object,
  878. default: () => {
  879. return {
  880. countKey: 'saleCount',
  881. unitKey: 'saleUnit',
  882. unitIdKey: 'saleUnitId'
  883. };
  884. }
  885. }
  886. },
  887. data() {
  888. const defaultForm = {
  889. key: null,
  890. endTime: '',
  891. isFirst: 0,
  892. name: '',
  893. startTime: '',
  894. workHour: '',
  895. guaranteePeriodUnitCode: '',
  896. technicalDrawings: [],
  897. arrivalWay:1
  898. };
  899. return {
  900. levelList,
  901. taskinstanceDialogFlag: false,
  902. allPrice: 0,
  903. numberReg,
  904. defaultForm,
  905. form: {
  906. datasource: [],
  907. discountTotalPrice: 0
  908. },
  909. pricingWayList,
  910. curIndex: '',
  911. rules: {},
  912. dictList: {},
  913. arrivalWayList: [
  914. { label: '一次性到货', value: 1 },
  915. { label: '分批到货', value: 2 }
  916. ],
  917. columnsVersion:1
  918. };
  919. },
  920. computed: {
  921. canHandl() {
  922. return this.form.datasource.length;
  923. },
  924. columns() {
  925. let columnsVersion=this.columnsVersion
  926. let orderColumn = {
  927. width: 1,
  928. show: false
  929. };
  930. if (this.isOrderNo) {
  931. orderColumn = {
  932. minWidth: 200,
  933. prop: 'orderNo',
  934. slot: 'orderNo',
  935. label: '订单编码',
  936. showOverflowTooltip: true,
  937. align: 'center'
  938. };
  939. }
  940. return [
  941. {
  942. width: 45,
  943. type: 'index',
  944. columnKey: 'index',
  945. align: 'center',
  946. fixed: 'left'
  947. },
  948. orderColumn,
  949. {
  950. width: 280,
  951. prop: 'productName',
  952. label: '名称',
  953. slot: 'productName',
  954. headerSlot: 'headerProductName',
  955. align: 'center',
  956. fixed: 'left'
  957. },
  958. {
  959. width: 120,
  960. prop: 'productCode',
  961. label: '编码',
  962. slot: 'productCode',
  963. align: 'center'
  964. },
  965. {
  966. width: 200,
  967. prop: 'productCategoryName',
  968. label: '类型',
  969. slot: 'productCategoryName',
  970. align: 'center'
  971. },
  972. {
  973. width: 120,
  974. prop: 'specification',
  975. label: '规格',
  976. slot: 'specification',
  977. align: 'center'
  978. },
  979. {
  980. width: 200,
  981. prop: 'customerMark',
  982. label: this.contractBookType == 1 ? '客户代号' : '供应商代号',
  983. slot: 'customerMark',
  984. headerSlot: 'headerCustomerMark',
  985. align: 'center'
  986. },
  987. {
  988. minWidth: 240,
  989. prop: 'taskName',
  990. label: '工序',
  991. slot: 'taskName',
  992. align: 'center'
  993. },
  994. {
  995. minWidth: 160,
  996. prop: 'productionCodes',
  997. label: '生产编号',
  998. align: 'center'
  999. },
  1000. {
  1001. minWidth: 120,
  1002. prop: 'entrustedEnterpriseId',
  1003. label: '受托企业',
  1004. slot: 'entrustedEnterpriseId',
  1005. show: this.isCustomerMark,
  1006. align: 'center'
  1007. },
  1008. {
  1009. width: 150,
  1010. prop: 'saleCount',
  1011. label: '数量',
  1012. slot: 'saleCount',
  1013. headerSlot: 'headerTotalCount',
  1014. align: 'center'
  1015. },
  1016. {
  1017. width: 150,
  1018. prop: 'saleUnit',
  1019. label: '单位',
  1020. slot: 'saleUnit',
  1021. // headerSlot: 'headerTotalCount',
  1022. align: 'center'
  1023. },
  1024. {
  1025. width: 120,
  1026. prop: 'packingSpecification',
  1027. align: 'center',
  1028. label: '包装规格',
  1029. showOverflowTooltip: true
  1030. },
  1031. {
  1032. width: 150,
  1033. prop: 'totalCount',
  1034. label: '计量数量',
  1035. // slot: 'totalCount',
  1036. headerSlot: 'headerTotalCount',
  1037. align: 'center'
  1038. },
  1039. {
  1040. width: 120,
  1041. prop: 'measuringUnit',
  1042. label: '计量单位',
  1043. slot: 'measuringUnit',
  1044. align: 'center'
  1045. },
  1046. // {
  1047. // width: 160,
  1048. // prop: 'pricingWay',
  1049. // label: '计价方式',
  1050. // headerSlot: 'headerPricingWay',
  1051. // slot: 'pricingWay',
  1052. // align: 'center'
  1053. // },
  1054. {
  1055. minWidth: 120,
  1056. prop: 'goodsLevel',
  1057. label: '物品级别',
  1058. slot: 'goodsLevel',
  1059. align: 'center'
  1060. },
  1061. {
  1062. width: 160,
  1063. prop: 'goodsPriceType',
  1064. label: '价格类型',
  1065. slot: 'goodsPriceType',
  1066. align: 'center'
  1067. },
  1068. {
  1069. width: 200,
  1070. prop: 'singlePrice',
  1071. label: '单价',
  1072. slot: 'singlePrice',
  1073. headerSlot: 'headerSinglePrice',
  1074. align: 'center'
  1075. },
  1076. {
  1077. width: 160,
  1078. prop: 'taxRate',
  1079. label: '税率',
  1080. slot: 'taxRate',
  1081. align: 'center'
  1082. },
  1083. {
  1084. width: 180,
  1085. prop: 'notaxSinglePrice',
  1086. label: '不含税单价',
  1087. slot: 'notaxSinglePrice',
  1088. align: 'center'
  1089. },
  1090. {
  1091. width: 160,
  1092. prop: 'discountSinglePrice',
  1093. label: '折让单价',
  1094. align: 'center',
  1095. show: this.isDiscount,
  1096. formatter: (_row, _column, cellValue) => {
  1097. return _row.discountSinglePrice
  1098. ? Number(_row.discountSinglePrice).toFixed(2)
  1099. : '';
  1100. }
  1101. },
  1102. {
  1103. width: 120,
  1104. prop: 'totalPrice',
  1105. label: '合计',
  1106. slot: 'totalPrice',
  1107. align: 'center'
  1108. },
  1109. {
  1110. width: 160,
  1111. prop: 'discountTotalPrice',
  1112. label: '折让合计',
  1113. align: 'center',
  1114. show: this.isDiscount,
  1115. formatter: (_row, _column, cellValue) => {
  1116. return _row.discountTotalPrice
  1117. ? Number(_row.discountTotalPrice).toFixed(2)
  1118. : '';
  1119. }
  1120. },
  1121. {
  1122. width: 110,
  1123. prop: 'batchNo',
  1124. label: '批次号',
  1125. slot: 'batchNo',
  1126. align: 'center'
  1127. },
  1128. {
  1129. width: 120,
  1130. prop: 'availableCountBase',
  1131. label: '库存数量',
  1132. slot: 'availableCountBase',
  1133. align: 'center'
  1134. },
  1135. {
  1136. prop: 'provenance',
  1137. label: '产地',
  1138. slot: 'provenance',
  1139. align: 'center',
  1140. showOverflowTooltip: true,
  1141. minWidth: 200
  1142. // show:this.contractBookType==2
  1143. },
  1144. {
  1145. width: 120,
  1146. prop: 'singleWeight',
  1147. label: '单重',
  1148. slot: 'singleWeight',
  1149. headerSlot: 'headerSingleWeight',
  1150. align: 'center'
  1151. },
  1152. {
  1153. width: 120,
  1154. prop: 'totalWeight',
  1155. label: '总重',
  1156. slot: 'totalWeight',
  1157. align: 'center'
  1158. },
  1159. {
  1160. width: 120,
  1161. prop: 'weightUnit',
  1162. label: '重量单位',
  1163. slot: 'weightUnit',
  1164. align: 'center'
  1165. },
  1166. {
  1167. width: 160,
  1168. prop: 'productBrand',
  1169. label: '牌号',
  1170. slot: 'productBrand',
  1171. align: 'center'
  1172. },
  1173. {
  1174. width: 120,
  1175. prop: 'modelType',
  1176. label: '型号',
  1177. slot: 'modelType',
  1178. align: 'center'
  1179. },
  1180. {
  1181. width: 120,
  1182. prop: 'produceType',
  1183. align: 'center',
  1184. label: '属性类型',
  1185. showOverflowTooltip: true,
  1186. formatter: (row, column) => {
  1187. if (row.produceType) {
  1188. return row.produceType
  1189. .map((item) => {
  1190. return lbjtList[item];
  1191. })
  1192. .toString();
  1193. }
  1194. }
  1195. },
  1196. {
  1197. width: 160,
  1198. prop: 'arrivalWay',
  1199. label: '到货方式',
  1200. slot: 'arrivalWay',
  1201. align: 'center',
  1202. show: this.isArrivalWay
  1203. },
  1204. {
  1205. width: 160,
  1206. prop: 'customerExpectDeliveryDeadline',
  1207. label: this.contractBookType == 1 ? '客户期望交期' : '交付日期',
  1208. slot: 'customerExpectDeliveryDeadline',
  1209. headerSlot: 'headerCustomerExpectDeliveryDeadline',
  1210. align: 'center'
  1211. },
  1212. {
  1213. width: 160,
  1214. prop: 'produceDeliveryDeadline',
  1215. label: '生产交付交期',
  1216. slot: 'produceDeliveryDeadline',
  1217. headerSlot: 'headerProduceDeliveryDeadline',
  1218. show: this.contractBookType == 1,
  1219. align: 'center'
  1220. },
  1221. {
  1222. width: 200,
  1223. prop: 'guaranteePeriod',
  1224. label: '有效期',
  1225. slot: 'guaranteePeriod',
  1226. // headerSlot: 'headerGuaranteePeriod',
  1227. align: 'center'
  1228. },
  1229. {
  1230. width: 200,
  1231. prop: 'guaranteePeriodDeadline',
  1232. label: '有效期截止日期',
  1233. slot: 'guaranteePeriodDeadline',
  1234. show: this.isGuaranteePeriod,
  1235. align: 'center'
  1236. },
  1237. {
  1238. width: 120,
  1239. prop: 'imgCode',
  1240. align: 'center',
  1241. label: '图号/件号',
  1242. showOverflowTooltip: true
  1243. },
  1244. // {
  1245. // width: 120,
  1246. // prop: 'approvalNumber',
  1247. // align: 'center',
  1248. // label: '批准文号',
  1249. // showOverflowTooltip: true
  1250. // },
  1251. {
  1252. width: 220,
  1253. prop: 'customerReqFiles',
  1254. label: '客户需求',
  1255. slot: 'customerReqFiles',
  1256. align: 'center'
  1257. },
  1258. {
  1259. width: 130,
  1260. prop: 'technicalAnswerName',
  1261. label: '技术答疑人',
  1262. slot: 'technicalAnswerName',
  1263. align: 'center'
  1264. },
  1265. {
  1266. width: 220,
  1267. prop: 'technicalParams',
  1268. label: '技术参数',
  1269. slot: 'technicalParams',
  1270. align: 'center'
  1271. },
  1272. {
  1273. width: 240,
  1274. prop: 'technicalDrawings',
  1275. label: '技术图纸',
  1276. slot: 'technicalDrawings',
  1277. align: 'center'
  1278. },
  1279. {
  1280. width: 120,
  1281. prop: 'drawingVersion',
  1282. label: '图纸版本',
  1283. align: 'center'
  1284. },
  1285. {
  1286. width: 240,
  1287. prop: 'technologyRouteName',
  1288. label: '工艺路线',
  1289. slot: 'technologyRouteName',
  1290. align: 'center'
  1291. },
  1292. {
  1293. width: 240,
  1294. prop: 'industryArtFiles',
  1295. label: '工艺附件',
  1296. slot: 'industryArtFiles',
  1297. align: 'center'
  1298. },
  1299. {
  1300. width: 240,
  1301. prop: 'otherFiles',
  1302. label: '其他附件',
  1303. slot: 'otherFiles',
  1304. align: 'center'
  1305. },
  1306. {
  1307. width: 220,
  1308. prop: 'remark',
  1309. label: '备注',
  1310. slot: 'remark',
  1311. align: 'center'
  1312. },
  1313. {
  1314. columnKey: 'action',
  1315. label: '操作',
  1316. width: 120,
  1317. align: 'center',
  1318. resizable: false,
  1319. slot: 'action',
  1320. fixed: 'right',
  1321. showOverflowTooltip: true
  1322. }
  1323. ];
  1324. }
  1325. },
  1326. created() {
  1327. this.requestDict('保质期单位');
  1328. this.requestDict('产地');
  1329. this.requestDict('商品价格类型');
  1330. },
  1331. methods: {
  1332. packingChange(item, index) {
  1333. this.$set(
  1334. this.form.datasource[index],
  1335. this.countObj.unitKey,
  1336. item.conversionUnit
  1337. );
  1338. },
  1339. openVersion(index) {
  1340. this.$refs.versionRefs.open(index);
  1341. },
  1342. //设置分批到货时间
  1343. handleMethod(row, index) {
  1344. this.$refs.timeDialogRef.open(row, index);
  1345. },
  1346. chooseTime({ arrivalBatch, index }) {
  1347. this.$set(
  1348. this.form.datasource[index],
  1349. 'arrivalBatch',
  1350. copyObj(arrivalBatch)
  1351. );
  1352. },
  1353. //工艺路线
  1354. changeProduct(data, index) {
  1355. this.$set(
  1356. this.form.datasource[index],
  1357. 'technologyRouteName',
  1358. data.name
  1359. );
  1360. this.$set(this.form.datasource[index], 'technologyRouteId', data.id);
  1361. },
  1362. handleTaskinstance(row, index) {
  1363. this.taskinstanceDialogFlag = true;
  1364. this.$nextTick(() => {
  1365. this.$refs.taskinstanceDialogRef.open(row, index);
  1366. });
  1367. },
  1368. saveTaskInstance(row = {}) {
  1369. this.$set(this.form.datasource[row.index], 'taskId', row.id);
  1370. this.$set(this.form.datasource[row.index], 'taskName', row.name);
  1371. this.$set(
  1372. this.form.datasource[row.index],
  1373. 'routingId',
  1374. row.produceRoutingId
  1375. );
  1376. },
  1377. async getSupplierObj(productList, queryName) {
  1378. try {
  1379. let categoryIds = productList
  1380. .filter((item) => item.productId)
  1381. .map((item) => item.productId);
  1382. if (categoryIds.length > 0) {
  1383. return await contactQueryByCategoryIdsAPI({
  1384. categoryIds,
  1385. isQueryEE: 1
  1386. });
  1387. } else {
  1388. return Promise.resolve({});
  1389. }
  1390. } catch (e) {
  1391. return Promise.resolve({});
  1392. }
  1393. },
  1394. setDeliveryDays(row, index, type, isAll) {
  1395. if (isAll) {
  1396. this.form.datasource.forEach((item, i) => {
  1397. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  1398. item.guaranteePeriodUnitCode
  1399. );
  1400. this.$set(
  1401. this.form.datasource[i],
  1402. 'guaranteePeriodDeadline',
  1403. guaranteePeriodUnitName != 'second'
  1404. ? this.setDay(
  1405. item.guaranteePeriod,
  1406. guaranteePeriodUnitName,
  1407. item
  1408. )
  1409. : ''
  1410. );
  1411. // }
  1412. });
  1413. return;
  1414. }
  1415. if (type == 'guaranteePeriod') {
  1416. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  1417. row.guaranteePeriodUnitCode
  1418. );
  1419. this.$set(
  1420. this.form.datasource[index],
  1421. 'guaranteePeriodDeadline',
  1422. guaranteePeriodUnitName != 'second'
  1423. ? this.setDay(row.guaranteePeriod, guaranteePeriodUnitName, row)
  1424. : ''
  1425. );
  1426. }
  1427. },
  1428. guaranteePeriodUnit(code) {
  1429. return code == 3
  1430. ? 'day'
  1431. : code == 4
  1432. ? 'month'
  1433. : code == 5
  1434. ? 'year'
  1435. : 'second';
  1436. },
  1437. setDay(addDay, dateType = 'day', item) {
  1438. let tiem =
  1439. this.contractBookType == 1
  1440. ? item.produceDeliveryDeadline
  1441. : item.customerExpectDeliveryDeadline;
  1442. return dayjs(tiem || new Date())
  1443. .add(addDay, dateType)
  1444. .format('YYYY-MM-DD');
  1445. },
  1446. // 返回列表数据
  1447. getTableValue() {
  1448. let comitDatasource = this.form.datasource;
  1449. if (comitDatasource.length === 0) return [];
  1450. comitDatasource.forEach((v) => {
  1451. if (v.guaranteePeriodUnitCode) {
  1452. v.guaranteePeriodUnitName = this.getDictValue(
  1453. '保质期单位',
  1454. v.guaranteePeriodUnitCode
  1455. );
  1456. }
  1457. v.technicalDrawings = v.technicalDrawings ? v.technicalDrawings : [];
  1458. v.customerReqFiles = v.customerReqFiles || [];
  1459. v.industryArtFiles = v.industryArtFiles || [];
  1460. v.otherFiles = v.otherFiles || [];
  1461. });
  1462. return comitDatasource;
  1463. },
  1464. getPrice() {
  1465. return [this.allPrice, this.form.discountTotalPrice];
  1466. },
  1467. //改变数量
  1468. changeCount(row, index) {
  1469. if (!row) {
  1470. this.form.datasource.forEach((item, index) => {
  1471. this.$set(
  1472. this.form,
  1473. 'datasource[' + index + ']',
  1474. changeCount(item, this.countObj)
  1475. );
  1476. });
  1477. } else {
  1478. this.$set(
  1479. this.form,
  1480. 'datasource[' + index + ']',
  1481. changeCount(row, this.countObj)
  1482. );
  1483. }
  1484. this.getNotaxSinglePrice();
  1485. this.changeAll();
  1486. this.$forceUpdate();
  1487. },
  1488. changeAll() {
  1489. this.allPrice = getAllPrice(this.form.datasource) || 0;
  1490. if (this.isDiscountTotalPrice) {
  1491. this.form.discountTotalPrice = this.allPrice;
  1492. this.$emit('setDiscountTotalPrice', this.allPrice);
  1493. }
  1494. this.$emit('setCountAmount', this.allPrice);
  1495. },
  1496. setCustomerMark(customerMark) {
  1497. this.form.datasource.forEach((item) => {
  1498. item['customerMark'] = customerMark;
  1499. this.$forceUpdate();
  1500. });
  1501. },
  1502. //计算不含税单价
  1503. getNotaxSinglePrice() {
  1504. this.form.datasource.forEach((item, index) => {
  1505. if (item.singlePrice && item.taxRate) {
  1506. this.$set(
  1507. this.form.datasource[index],
  1508. 'notaxSinglePrice',
  1509. parseFloat(
  1510. (item.singlePrice / (1 + item.taxRate / 100)).toFixed(2)
  1511. )
  1512. );
  1513. } else {
  1514. this.$set(this.form.datasource[index], 'notaxSinglePrice', '');
  1515. }
  1516. });
  1517. },
  1518. //设置优惠后总金额修改产品单价
  1519. discountInputByOrder(val) {
  1520. this.form.discountTotalPrice = val;
  1521. // //获取优惠金额和总计的差价
  1522. this.form.datasource.forEach((item, index) => {
  1523. //获取折让单价
  1524. this.$set(
  1525. this.form.datasource[index],
  1526. 'discountSinglePrice',
  1527. this.getDiscountSinglePrice(item)
  1528. );
  1529. this.$set(
  1530. this.form.datasource[index],
  1531. 'discountTotalPrice',
  1532. this.getDiscountTotalPrice(item)
  1533. );
  1534. });
  1535. this.$emit('setDiscountTotalPrice', val);
  1536. this.$forceUpdate();
  1537. this.$refs.table.reRenderTable();
  1538. },
  1539. //获取折让单价
  1540. getDiscountSinglePrice(row) {
  1541. let num =
  1542. (Number(this.form.discountTotalPrice) / Number(this.allPrice)) *
  1543. Number(row.singlePrice);
  1544. console.log(num, 'num');
  1545. return isNaN(num) ? '' : num;
  1546. },
  1547. //获取折让合计
  1548. getDiscountTotalPrice(row) {
  1549. let num = 0;
  1550. num = Number(row.discountSinglePrice) * Number(row.totalCount);
  1551. return isNaN(num) ? '' : num.toFixed(2);
  1552. },
  1553. orderNoChange(row, item) {
  1554. row['orderId'] = item.orderId;
  1555. },
  1556. //修改回显
  1557. async putTableValue(data) {
  1558. let productList =
  1559. (data &&
  1560. (data.quoteProductList || data.productList || data.detailList)) ||
  1561. [];
  1562. if (productList) {
  1563. let supplierObj = await this.getSupplierObj(productList, 'productId');
  1564. productList.forEach((item) => {
  1565. item.pricingWay =
  1566. item.pricingWay ||
  1567. data.pricingWay ||
  1568. data?.contractVO?.pricingWay;
  1569. item.guaranteePeriodUnitCode = item.guaranteePeriodUnitCode
  1570. ? item.guaranteePeriodUnitCode + ''
  1571. : '';
  1572. let guaranteePeriodUnitName = this.guaranteePeriodUnit(
  1573. item.guaranteePeriodUnitCode
  1574. );
  1575. if (item.guaranteePeriod && item.guaranteePeriodUnitCode) {
  1576. item['guaranteePeriodDeadline'] =
  1577. item['guaranteePeriodDeadline'] ||
  1578. guaranteePeriodUnitName != 'second'
  1579. ? this.setDay(
  1580. item.guaranteePeriod,
  1581. guaranteePeriodUnitName,
  1582. item
  1583. )
  1584. : '';
  1585. }
  1586. item.entrustedEnterpriseIdList = supplierObj[item.productId];
  1587. if (supplierObj[item.productId]?.length === 1) {
  1588. item.entrustedEnterpriseId = supplierObj[item.productId][0].id;
  1589. }
  1590. item['customerMark'] = item.customerMark || this.customerMark;
  1591. item['arrivalWay'] = item.arrivalWay || 1;
  1592. });
  1593. this.form.datasource = productList;
  1594. let codeList = this.form.datasource
  1595. .filter((item) => item.productCode)
  1596. .map((item) => item.productCode);
  1597. //获取仓库库存
  1598. let inventoryTotalList = await getInventoryTotalAPI(codeList);
  1599. this.form.datasource
  1600. .filter((item) => item.productCode)
  1601. .forEach((item, index) => {
  1602. let find =
  1603. inventoryTotalList.find(
  1604. (key) => key.code == item.productCode
  1605. ) || {};
  1606. this.form.datasource;
  1607. this.$set(
  1608. this.form.datasource[index],
  1609. 'availableCountBase',
  1610. find.availableCountBase
  1611. );
  1612. });
  1613. if (this.isChangeCount) {
  1614. this.changeCount();
  1615. } else {
  1616. this.allPrice = data.totalAmount || data?.contractVO?.totalPrice;
  1617. }
  1618. if (this.isDiscountTotalPrice) {
  1619. this.form.discountTotalPrice =
  1620. data.payAmount || data?.contractVO?.discountTotalPrice;
  1621. }
  1622. this.$refs.table.reload();
  1623. }
  1624. },
  1625. //计算单重
  1626. //选择产品
  1627. handParent(row, index) {
  1628. let item = {
  1629. id: row?.productCode
  1630. };
  1631. if (row?.goodsId) {
  1632. this.handGoods(index);
  1633. return;
  1634. }
  1635. if (this.needProduce == 1 || this.needProduce == 2) {
  1636. this.$refs.productListRef.open(item, index);
  1637. } else {
  1638. this.$refs.selectStockLedgerDialogRef.open(item, index);
  1639. }
  1640. },
  1641. handGoods(index) {
  1642. this.$refs.commodityPriceListDialogRef.open(index);
  1643. },
  1644. //选择技术人回调
  1645. changeAnswer(obj, idx) {
  1646. this.$set(this.form.datasource[idx], 'technicalAnswerId', obj.id);
  1647. this.$set(this.form.datasource[idx], 'technicalAnswerName', obj.name);
  1648. },
  1649. handHead(row, index) {
  1650. let item = {
  1651. id: row.technicalAnswerId
  1652. };
  1653. this.$refs.headRef.open(item, index);
  1654. },
  1655. //选择产品回调
  1656. changeParent(obj, idx) {
  1657. obj.forEach((item, index) => {
  1658. let i = idx == -1 ? index : idx;
  1659. let row = JSON.parse(JSON.stringify(this.defaultForm));
  1660. row.key = this.form.datasource.length + 1;
  1661. let parasm = idx == -1 ? row : this.form.datasource[i];
  1662. this.$set(parasm, 'productId', item.id);
  1663. this.$set(parasm, 'categoryName', item.name);
  1664. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  1665. this.$set(parasm, 'productBrand', item.brandNum);
  1666. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  1667. this.$set(parasm, 'productCode', item.code);
  1668. this.$set(parasm, 'productName', item.name);
  1669. this.$set(parasm, 'modelType', item.modelType);
  1670. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  1671. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  1672. this.$set(parasm, 'specification', item.specification);
  1673. this.$set(parasm, 'weightUnit', item.weightUnit);
  1674. this.$set(parasm, 'singleWeight', item.netWeight);
  1675. this.$set(parasm, 'pricingWay', 1);
  1676. console.log(item.goodsLevel,'item.goodsLevel')
  1677. this.$set(parasm, 'goodsLevel', item.goodsLevel);
  1678. this.$set(
  1679. parasm,
  1680. 'packageDispositionList',
  1681. item.packageDispositionList
  1682. );
  1683. if (item.packageDispositionList?.length) {
  1684. this.$set(
  1685. parasm,
  1686. this.countObj.unitIdKey,
  1687. item.packageDispositionList[0].id
  1688. );
  1689. this.$set(
  1690. parasm,
  1691. this.countObj.unitKey,
  1692. item.packageDispositionList[0].conversionUnit
  1693. );
  1694. }
  1695. this.$set(parasm, 'arrivalWay', item.arrivalWay || 1);
  1696. this.$set(parasm, 'imgCode', item.imgCode);
  1697. this.$set(parasm, 'produceType', item.componentAttribute);
  1698. if (this.isOrderNo) {
  1699. this.$set(parasm, 'orderNo', this.orderOption[0]?.orderNo);
  1700. this.$set(parasm, 'orderId', this.orderOption[0]?.orderId);
  1701. }
  1702. if (this.isGoods) {
  1703. this.$set(parasm, 'goodsId', item.goodsId);
  1704. this.$set(parasm, 'goodsPriceId', item.goodsPriceId);
  1705. this.$set(parasm, 'goodsPriceType', item.goodsPriceType);
  1706. this.$set(parasm, 'singlePrice', item.singlePrice);
  1707. this.$set(parasm, 'notaxSinglePrice', item.notaxSinglePrice);
  1708. this.$set(parasm, 'taxRate', item.taxRate);
  1709. this.$set(parasm, 'discountSinglePrice', item.singlePrice);
  1710. this.$set(parasm, 'totalCount', '');
  1711. }
  1712. if (this.isSupplier) {
  1713. this.$set(
  1714. parasm,
  1715. 'entrustedEnterpriseIdList',
  1716. item.entrustedEnterpriseIdList
  1717. );
  1718. this.$set(
  1719. parasm,
  1720. 'entrustedEnterpriseId',
  1721. item.entrustedEnterpriseId
  1722. );
  1723. }
  1724. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  1725. this.$set(
  1726. parasm,
  1727. 'packingSpecification',
  1728. item.extField.packingSpecification
  1729. );
  1730. this.$set(parasm, 'customerMark', this.customerMark);
  1731. if (item.purchaseOrigins?.length > 0) {
  1732. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  1733. }
  1734. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  1735. if (idx == -1) {
  1736. this.form.datasource.push(row);
  1737. }
  1738. });
  1739. this.changeCount();
  1740. },
  1741. replaceTable(obj, idx) {
  1742. obj.forEach((item, index) => {
  1743. let i = idx == -1 ? index : idx;
  1744. let row = JSON.parse(JSON.stringify(this.defaultForm));
  1745. row.key = this.form.datasource.length + 1;
  1746. let parasm = idx == -1 ? row : this.form.datasource[i];
  1747. this.$set(parasm, 'customerMark', this.customerMark);
  1748. this.$set(parasm, 'productId', item.productId);
  1749. this.$set(parasm, 'categoryName', item.productName);
  1750. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  1751. this.$set(parasm, 'productBrand', item.productBrand);
  1752. this.$set(parasm, 'productCategoryName', item.categoryLevelPath);
  1753. this.$set(parasm, 'productCode', item.productCode);
  1754. this.$set(parasm, 'productName', item.productName);
  1755. this.$set(parasm, 'modelType', item.categoryModel);
  1756. this.$set(parasm, 'availableCountBase', item.measureQuantity);
  1757. this.$set(parasm, 'measuringUnit', item.measuringUnit);
  1758. this.$set(parasm, 'specification', item.specification);
  1759. this.$set(parasm, 'weightUnit', item.weightUnit);
  1760. this.$set(parasm, 'singleWeight', item.weight);
  1761. this.$set(parasm, 'pricingWay', 1);
  1762. this.$set(parasm, 'arrivalWay', item.arrivalWay || 1);
  1763. this.$set(parasm, 'imgCode', '');
  1764. this.$set(parasm, 'produceType', item.componentAttribute);
  1765. if (this.isSupplier) {
  1766. this.$set(
  1767. parasm,
  1768. 'entrustedEnterpriseIdList',
  1769. item.entrustedEnterpriseIdList
  1770. );
  1771. this.$set(
  1772. parasm,
  1773. 'entrustedEnterpriseId',
  1774. item.entrustedEnterpriseId
  1775. );
  1776. }
  1777. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  1778. this.$set(
  1779. parasm,
  1780. 'packingSpecification',
  1781. item.extField.packingSpecification
  1782. );
  1783. this.$set(
  1784. parasm,
  1785. 'packageDispositionList',
  1786. item.packageDispositionList
  1787. );
  1788. if (item.packageDispositionList?.length) {
  1789. this.$set(
  1790. parasm,
  1791. this.countObj.unitIdKey,
  1792. item.packageDispositionList[0].id
  1793. );
  1794. this.$set(
  1795. parasm,
  1796. this.countObj.unitKey,
  1797. item.packageDispositionList[0].conversionUnit
  1798. );
  1799. }
  1800. this.$set(parasm, 'customerMark', this.customerMark);
  1801. if (item.purchaseOrigins?.length > 0) {
  1802. item.purchaseOrigins = item.purchaseOrigins.map((val) => val + '');
  1803. }
  1804. this.$set(parasm, 'provenance', item.purchaseOrigins || []);
  1805. if (this.isSupplier) {
  1806. this.$set(
  1807. parasm,
  1808. 'entrustedEnterpriseIdList',
  1809. item.entrustedEnterpriseIdList
  1810. );
  1811. this.$set(
  1812. parasm,
  1813. 'entrustedEnterpriseId',
  1814. item.entrustedEnterpriseId
  1815. );
  1816. }
  1817. if (idx == -1) {
  1818. this.form.datasource.push(row);
  1819. }
  1820. });
  1821. },
  1822. remove(index) {
  1823. this.form.datasource.splice(index, 1);
  1824. this.setSort();
  1825. this.changeAll();
  1826. },
  1827. // 重新排序
  1828. setSort() {
  1829. this.form.datasource.forEach((n, index) => {
  1830. n.key = index + 1;
  1831. });
  1832. },
  1833. // 添加
  1834. handlAdd() {
  1835. let item = JSON.parse(JSON.stringify(this.defaultForm));
  1836. item.key = this.form.datasource.length + 1;
  1837. item.customerMark = this.customerMark;
  1838. this.form.datasource.push(item);
  1839. },
  1840. validateForm(callback) {
  1841. // let singleWeightData = {};
  1842. // this.form.datasource.forEach((item) => {
  1843. // if (item.pricingWay == 2 && !item.singleWeight) {
  1844. // singleWeightData['name'] = item.productName;
  1845. // console.log(singleWeightData, 'singleWeightData');
  1846. // }
  1847. // });
  1848. // if (singleWeightData.name) {
  1849. // this.$message.warning(
  1850. // singleWeightData.name + '计价方式为按重量计费,单重不能为空'
  1851. // );
  1852. // callback(false);
  1853. // }
  1854. //开始表单校验
  1855. this.$refs.form.validate((valid, obj) => {
  1856. if (obj) {
  1857. let messages = Object.keys(obj).map((key) => obj[key][0]);
  1858. if (messages.length > 0) {
  1859. this.$message.warning(messages[0].message);
  1860. }
  1861. }
  1862. callback(valid);
  1863. });
  1864. },
  1865. goodsPriceTypeChange(row, index) {
  1866. if (row.goodsId) {
  1867. getGoodsPriceByCondition({
  1868. id: row.goodsId,
  1869. priceType: row.goodsPriceType
  1870. }).then((res) => {
  1871. if (res.id) {
  1872. this.$set(this.form.datasource[index], 'goodsPriceId', res.id);
  1873. this.$set(
  1874. this.form.datasource[index],
  1875. 'goodsPriceType',
  1876. res.priceType
  1877. );
  1878. this.$set(
  1879. this.form.datasource[index],
  1880. 'singlePrice',
  1881. res.unitPrice
  1882. );
  1883. this.$set(
  1884. this.form.datasource[index],
  1885. 'notaxSinglePrice',
  1886. res.excludeTaxPrice
  1887. );
  1888. this.$set(this.form.datasource[index], 'taxRate', res.taxRate);
  1889. this.$set(
  1890. this.form.datasource[index],
  1891. 'discountSinglePrice',
  1892. res.unitPrice
  1893. );
  1894. }
  1895. this.changeCount(row, index);
  1896. });
  1897. }
  1898. },
  1899. save() {
  1900. this.$emit('save');
  1901. }
  1902. }
  1903. };
  1904. </script>
  1905. <style lang="scss" scoped>
  1906. .headbox {
  1907. display: flex;
  1908. justify-content: space-between;
  1909. align-items: center;
  1910. .amount {
  1911. font-size: 14px;
  1912. font-weight: bold;
  1913. padding-right: 30px;
  1914. }
  1915. }
  1916. .time-form .el-form-item {
  1917. margin-bottom: 0 !important;
  1918. }
  1919. ::v-deep .period {
  1920. display: flex;
  1921. .borderleftnone {
  1922. .el-input--medium .el-input__inner {
  1923. border-top-right-radius: 0;
  1924. border-bottom-right-radius: 0;
  1925. }
  1926. }
  1927. .borderrightnone {
  1928. .el-input--medium .el-input__inner {
  1929. border-top-left-radius: 0;
  1930. border-bottom-left-radius: 0;
  1931. }
  1932. }
  1933. }
  1934. ::v-deep .time-form tbody > tr:hover > td {
  1935. background-color: transparent !important;
  1936. }
  1937. ::v-deep .time-form .el-table tr {
  1938. background-color: #ffffff;
  1939. }
  1940. .pricebox {
  1941. display: flex;
  1942. justify-content: flex-start;
  1943. align-items: center;
  1944. font-weight: bold;
  1945. }
  1946. </style>