produceList.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869
  1. <template>
  2. <view class="mainBox">
  3. <view v-for="(item, index) in tableList" :key="index" style="position: relative;">
  4. <myCard :item="item" :btnList="btnList" :index="index+1" :isDrawer="isDrawer" :columns="columns" @del="del(index)">
  5. <view class="slot-box" slot="productName">
  6. <u-row>
  7. <u-col span="10">
  8. <u--input placeholder="请输入" border="surround" disabled v-model="item.productName"></u--input>
  9. </u-col>
  10. <u-col span="2">
  11. <u-button v-if="!isDrawer" type="primary" size="mini" @click="selectProduct(item, index)" text="选择"></u-button>
  12. </u-col>
  13. </u-row>
  14. </view>
  15. <view slot="purchaseCount">
  16. <view v-if="isDrawer">
  17. {{ item.purchaseCount + ' ' + (item.purchaseUnit || '') }}
  18. </view>
  19. <view v-else>
  20. <u-row>
  21. <u-col span="6">
  22. <u--input placeholder="请输入" type="number" border="surround" v-model="item.purchaseCount" @input="changeCount(item, index)"></u--input>
  23. </u-col>
  24. <u-col span="6">
  25. <uni-data-picker v-model="item.purchaseUnitId" placeholder="请选择" :localdata="item.packageDispositionList" @change="changeCount(item, index)"></uni-data-picker>
  26. </u-col>
  27. </u-row>
  28. </view>
  29. </view>
  30. <view slot="goodsLevel">
  31. <view v-if="isDrawer">
  32. {{ getGoodsLevelVal(item.goodsLevel) }}
  33. </view>
  34. <view v-else>
  35. <uni-data-picker v-model="item.goodsLevel" placeholder="请选择" :localdata="levelList"></uni-data-picker>
  36. </view>
  37. </view>
  38. <view slot="arrivalWay">
  39. <view v-if="isDrawer">{{ item.arrivalWay == 1 ? '一次性到货' : '分批到货' }}</view>
  40. <view v-else>
  41. <uni-data-picker v-model="item.arrivalWay" placeholder="请选择" :localdata="arrivalWayList"></uni-data-picker>
  42. </view>
  43. </view>
  44. <view slot="expectReceiveDate">
  45. <view v-if="isDrawer">
  46. <view v-if="item.arrivalWay == 2" style="color: #409eff;" @click="settingDate(item, index)">分批时间</view>
  47. <view v-else>{{ item.expectReceiveDate }}</view>
  48. </view>
  49. <view v-else>
  50. <view v-if="item.arrivalWay == 2">
  51. <span @click="settingDate(item, index)" style="color: #409eff;">设置分批时间</span>
  52. </view>
  53. <view v-else>
  54. <uni-datetime-picker type="date" v-model="item.expectReceiveDate"></uni-datetime-picker>
  55. </view>
  56. </view>
  57. </view>
  58. <view slot="taskName">
  59. <view v-if="isDrawer">{{ item.taskName }}</view>
  60. <view v-else>
  61. <u-row>
  62. <u-col span="10">
  63. <u--input placeholder="" disabled border="surround" v-model="item.taskName"></u--input>
  64. </u-col>
  65. <u-col span="2">
  66. <u-button type="primary" size="mini" @click="selectTaskName(item, index)" text="选择"></u-button>
  67. </u-col>
  68. </u-row>
  69. </view>
  70. </view>
  71. <view slot="supplierName">
  72. <view v-if="isDrawer">{{ item.supplierName }}</view>
  73. <view v-else>
  74. <uni-data-picker v-model="item.supplierId" placeholder="请选择" :localdata="item.supplierList"></uni-data-picker>
  75. </view>
  76. </view>
  77. <view slot="provenance">
  78. <view v-if="isDrawer">{{ getProvenance(item.provenance) }}</view>
  79. <view v-else>
  80. <!-- <uni-data-picker v-model="item.provenance" placeholder="请选择" :localdata="purchase_origin"></uni-data-picker> -->
  81. <u--input placeholder="请输入" border="surround" v-model="item.provenanceName" @click.native="changeMultiple(item, index, 'provenance', purchase_origin)"></u--input>
  82. </view>
  83. </view>
  84. <view slot="brand">
  85. <view v-if="isDrawer">{{ item.brand }}</view>
  86. <view v-else>
  87. <u--input placeholder="请输入" border="surround" disabled v-model="item.productName"></u--input>
  88. </view>
  89. </view>
  90. <view slot="modelKey">
  91. <view v-if="isDrawer">{{ item.modelKey }}</view>
  92. <view v-else>
  93. <u--input placeholder="请输入" border="surround" v-model="item.modelKey" @click.native="changeMultiple(item, index, 'modelKey', product_model_key)"></u--input>
  94. </view>
  95. </view>
  96. <view slot="colorKey">
  97. <view v-if="isDrawer">{{ item.colorKey }}</view>
  98. <view v-else>
  99. <u--input placeholder="请输入" border="surround" v-model="item.colorKey" @click.native="changeMultiple(item, index, 'colorKey', product_color_key)"></u--input>
  100. </view>
  101. </view>
  102. <view slot="remark">
  103. <view v-if="isDrawer">{{ item.remark }}</view>
  104. <view v-else>
  105. <u--input placeholder="请输入" border="surround" v-model="item.remark"></u--input>
  106. </view>
  107. </view>
  108. <view slot="technicalDrawings" style="display: flex;">
  109. <fileMain :type="isDrawer ? 'view' : ''" v-model="item.technicalDrawings"></fileMain>
  110. </view>
  111. <view slot="files" style="display: flex;">
  112. <fileMain :type="isDrawer ? 'view' : ''" v-model="item.files"></fileMain>
  113. </view>
  114. </myCard>
  115. </view>
  116. <view style="height: 84rpx;" v-if="!isDrawer"></view>
  117. <!-- <view class="footerButton" v-if="!isDrawer">
  118. <u-button type="primary" @click="save" text="保存"></u-button>
  119. </view> -->
  120. <view class="add" @click="add" v-if="!isDrawer">
  121. <u-icon name="plus" color="#fff"></u-icon>
  122. </view>
  123. <u-action-sheet :actions="addList" :show="show" :closeOnClickOverlay="true" :closeOnClickAction="true"
  124. @close="show=false" @select='select'> </u-action-sheet>
  125. <timePopup ref="timePopupRef"
  126. :isView="isDrawer"
  127. @confirm="handleTimeConfirm"></timePopup>
  128. <multipleSelect ref="multipleSelectRef" :range="multipleSelectRange" @confirm="handleMultipleConfirm"></multipleSelect>
  129. </view>
  130. </template>
  131. <!-- 名称,数量,到货方式,到货日期 -->
  132. <script>
  133. import {
  134. getByCode
  135. } from '@/api/pda/common.js'
  136. import myCard from './myCard.vue'
  137. import { mapActions, mapGetters } from 'vuex'
  138. import { levelList, lbjtList } from '@/enum/dict'
  139. import fileMain from "@/pages/doc/index.vue"
  140. import { changeCount } from '@/utils/setProduct.js';
  141. import timePopup from './timePopup.vue'
  142. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  143. import multipleSelect from './multipleSelect.vue'
  144. export default {
  145. data() {
  146. return {
  147. tableList: [],
  148. multipleSelectRange: [],
  149. addList: [
  150. { name: '选择物品清单', },
  151. { name: '新增临时产品', }
  152. ],
  153. arrivalWayList: [
  154. { text: '一次性到货', value: 1 },
  155. { text: '分批到货', value: 2 }
  156. ],
  157. show: false,
  158. purchaseUnitShow: false,
  159. current: {},
  160. currentIndex: -1,
  161. date_unit: [],
  162. product_color_key: [],
  163. product_model_key: [],
  164. purchase_origin: [],
  165. allPrice: '',
  166. btnList: [{
  167. name: '删除',
  168. apiName: 'del',
  169. btnType: 'error ',
  170. type: '2',
  171. pageUrl: '',
  172. judge: [{
  173. authorities: '',
  174. }, {
  175. // key: 'status',
  176. // value: [0, 3],
  177. fn: (row) => {
  178. return !this.isDrawer
  179. },
  180. }],
  181. }],
  182. defaultForm: {
  183. key: null,
  184. endTime: '',
  185. isFirst: 0,
  186. name: '',
  187. startTime: '',
  188. workHour: '',
  189. guaranteePeriodUnitCode: '',
  190. technicalDrawings: [],
  191. files: [],
  192. arrivalWay: 1,
  193. modelKey: '',
  194. colorKey: ''
  195. },
  196. levelList
  197. }
  198. },
  199. props: {
  200. isDrawer: {
  201. default: false
  202. },
  203. pricingWay: {
  204. default: 1
  205. },
  206. isTemporary: {
  207. //临时
  208. type: Boolean,
  209. default: false
  210. },
  211. contractId: '',
  212. },
  213. components: {
  214. myCard,
  215. fileMain,
  216. timePopup,
  217. baTreePicker,
  218. multipleSelect
  219. },
  220. computed: {
  221. ...mapGetters(['dict', 'getDict', 'getDictValue']),
  222. columns() {
  223. return [
  224. [{
  225. label: '名称:',
  226. prop: 'productName',
  227. slot: 'productName',
  228. type: 'title',
  229. className: 'perce100',
  230. isRequired: true,
  231. }],
  232. [{
  233. label: '编码:',
  234. prop: 'productCode'
  235. }, {
  236. label: '分类:',
  237. prop: 'productCategoryName',
  238. }],
  239. [{
  240. label: '数量:',
  241. prop: 'purchaseCount',
  242. slot: 'purchaseCount',
  243. className: 'perce100',
  244. isRequired: true,
  245. // formatter: (item) => {
  246. // if (item.purchaseCount) {
  247. // return item.purchaseCount + ' ' + (item.purchaseUnit || '');
  248. // }
  249. // }
  250. }],
  251. [
  252. {
  253. label: '计量数量:',
  254. prop: 'totalCount',
  255. formatter: (item) => {
  256. if (item.totalCount) {
  257. return item.totalCount + ' ' + (item.measuringUnit || '');
  258. }
  259. }
  260. },
  261. {
  262. label: '包装规格:',
  263. prop: 'packingSpecification',
  264. }
  265. ],
  266. [{
  267. label: '物品级别:',
  268. prop: 'goodsLevel',
  269. slot: 'goodsLevel',
  270. // formatter: (item) => {
  271. // return levelList.find((i) => i.value == item.goodsLevel)
  272. // ?.label;
  273. // },
  274. },
  275. {
  276. label: '库存数量:',
  277. prop: 'availableCountBase',
  278. }],
  279. [{
  280. label: '已采数量:',
  281. prop: 'doneTotalCount',
  282. formatter: (item) => {
  283. if (item.doneTotalCount) {
  284. return item.doneTotalCount + ' ' + (item.measuringUnit || '');
  285. }
  286. }
  287. }, {
  288. label: '待采数量:',
  289. prop: 'waitTotalCount',
  290. formatter: (item) => {
  291. if (item.waitTotalCount) {
  292. return item.waitTotalCount + ' ' + (item.measuringUnit || '');
  293. }
  294. }
  295. }],
  296. [{
  297. label: '工序:',
  298. prop: 'taskName',
  299. slot: 'taskName',
  300. className: 'perce100',
  301. }],
  302. [{
  303. label: '批次号:',
  304. prop: 'batchNo',
  305. }],
  306. [{
  307. label: '供应商:',
  308. prop: 'supplierName',
  309. slot: 'supplierName'
  310. }, {
  311. label: '产地:',
  312. prop: 'provenance',
  313. slot: 'provenance',
  314. // formatter: (item) => {
  315. // // return item.provenance
  316. // return item.provenance && item.provenance.length
  317. // ? item.provenance
  318. // .map((item) => this.getDictValue('产地', item))
  319. // .join(',')
  320. // : '';
  321. // }
  322. }],
  323. [{
  324. label: '型号:',
  325. prop: 'modelType',
  326. },{
  327. label: '牌号:',
  328. prop: 'productBrand',
  329. }],
  330. [{
  331. label: '规格:',
  332. prop: 'specification',
  333. }, {
  334. label: '品牌:',
  335. prop: 'brand',
  336. slot: 'brand'
  337. }],
  338. [{
  339. label: '机型:',
  340. prop: 'modelKey',
  341. slot: 'modelKey'
  342. }, {
  343. label: '颜色:',
  344. prop: 'colorKey',
  345. slot: 'colorKey'
  346. }],
  347. [{
  348. label: '到货方式:',
  349. prop: 'arrivalWay',
  350. slot: 'arrivalWay',
  351. isRequired: true,
  352. // formatter: (item) => {
  353. // return item.arrivalWay == 1 ? '一次性到货' : '分批到货';
  354. // },
  355. }],
  356. [{
  357. label: '到货日期:',
  358. prop: 'expectReceiveDate',
  359. slot: 'expectReceiveDate',
  360. isRequired: true,
  361. }, {
  362. label: '属性类型:',
  363. prop: 'produceType',
  364. formatter: (item) => {
  365. if (item.produceType) {
  366. return item.produceType
  367. .map((i) => {
  368. return lbjtList[i];
  369. })
  370. .toString();
  371. }
  372. }
  373. }],
  374. [{
  375. label: '图纸附件:',
  376. prop: 'technicalDrawings',
  377. slot: 'technicalDrawings',
  378. }, {
  379. label: '附件:',
  380. prop: 'files',
  381. slot: 'files',
  382. }],
  383. [{
  384. label: '备注:',
  385. prop: 'remark',
  386. slot: 'remark',
  387. className: 'perce100',
  388. }],
  389. [{
  390. label: '操作:',
  391. prop: 'action',
  392. type: 'action',
  393. className: 'perce100',
  394. }],
  395. ]
  396. },
  397. },
  398. created() {
  399. this.getByCode()
  400. // this.requestDict('产地')
  401. uni.$off('setProduceList')
  402. uni.$on('setProduceList', (data) => {
  403. console.log('setProduceList~~', data)
  404. data.forEach(item => {
  405. item['productId'] = item.id
  406. item['categoryName'] = item.name
  407. item['productCategoryId'] = item.categoryLevelId
  408. item['productBrand'] = item.brandNum
  409. item['productCategoryName'] = item.categoryLevelPath
  410. item['productCode'] = item.code
  411. item['productName'] = item.name
  412. item['approvalNumber'] = item.extField.approvalNumber
  413. item['packingSpecification'] = item.extField.packingSpecification
  414. item['packageDispositionList'] = item.packageDispositionList.map(i => {
  415. return {
  416. ...i,
  417. text: i.conversionUnit,
  418. value: i.id
  419. }
  420. })
  421. if (item.packageDispositionList?.length) {
  422. item['purchaseUnitId'] = item.packageDispositionList[0].id
  423. item['purchaseUnit'] = item.packageDispositionList[0].conversionUnit
  424. }
  425. })
  426. console.log(this.currentIndex, this.current)
  427. if(this.currentIndex > -1) {
  428. console.log(111)
  429. // 使用this.$set更新数组项
  430. if (data && data.length > 0) {
  431. this.$set(this.tableList, this.currentIndex, data[0]);
  432. }
  433. this.currentIndex = -1;
  434. this.current = {};
  435. } else {
  436. console.log(222)
  437. this.tableList.push(...data)
  438. }
  439. })
  440. uni.$off('setTaskName')
  441. uni.$on('setTaskName', (data) => {
  442. console.log('setTaskName~~', data)
  443. console.log(this.currentIndex, this.current)
  444. if(this.currentIndex > -1) {
  445. console.log(111)
  446. // 使用this.$set更新数组项
  447. if (data && data.length > 0) {
  448. this.$set(this.tableList[this.currentIndex], 'taskId', data[0].id);
  449. this.$set(this.tableList[this.currentIndex], 'taskName', data[0].name);
  450. this.$set(
  451. this.tableList[this.currentIndex],
  452. 'routingId',
  453. data[0].produceRoutingId
  454. );
  455. }
  456. this.currentIndex = -1;
  457. this.current = {};
  458. }
  459. })
  460. uni.$off('setPBomList')
  461. uni.$on('setPBomList', (data, idx = -1) => {
  462. console.log('setPBomList~~', data)
  463. data.forEach((item, index) => {
  464. let i = idx == -1 ? index : idx;
  465. let row = JSON.parse(JSON.stringify(this.defaultForm));
  466. row.key = this.tableList.length + 1;
  467. let parasm = idx == -1 ? row : this.tableList[i];
  468. this.$set(parasm, 'productId', item.id);
  469. // this.$set(parasm, 'id', item.id);
  470. this.$set(parasm, 'categoryName', item.name);
  471. this.$set(parasm, 'productCategoryId', item.categoryLevelId);
  472. this.$set(parasm, 'productBrand', item.brandNum);
  473. this.$set(
  474. parasm,
  475. 'productCategoryName',
  476. item.category.categoryLevelPath
  477. );
  478. this.$set(parasm, 'totalCount', item.dosage);
  479. this.$set(parasm, 'productCode', item.code);
  480. this.$set(parasm, 'productName', item.name);
  481. this.$set(parasm, 'availableCountBase', item.availableCountBase);
  482. this.$set(parasm, 'modelType', item.modelType);
  483. this.$set(parasm, 'weightUnit', item.unit);
  484. this.$set(parasm, 'measuringUnit', item.unit);
  485. this.$set(parasm, 'specification', item.specification);
  486. this.$set(parasm, 'remark', '');
  487. this.$set(parasm, 'imgCode', item.imgCode);
  488. this.$set(parasm, 'produceType', item.componentAttribute);
  489. this.$set(parasm, 'approvalNumber', item.extField?.approvalNumber);
  490. this.$set(parasm, 'goodsLevel', item.goodsLevel);
  491. this.$set(parasm, 'supplierList', item.supplierList);
  492. this.$set(parasm, 'supplierCode', item.supplierCode);
  493. this.$set(parasm, 'supplierId', item.supplierId);
  494. this.$set(parasm, 'supplierName', item.supplierName);
  495. // if (item.modelKey) {
  496. // this.$set(parasm, 'modelKey', item.modelKey.split(','));
  497. // }
  498. // if (item.colorKey) {
  499. // this.$set(parasm, 'colorKey', item.colorKey.split(','));
  500. // }
  501. this.$set(
  502. parasm,
  503. 'packageDispositionList',
  504. item.packageDispositionList?.map(i => {
  505. return {
  506. ...i,
  507. text: i.conversionUnit,
  508. value: i.id
  509. }
  510. }) || []
  511. );
  512. if (item.packageDispositionList?.length) {
  513. this.$set(
  514. parasm,
  515. 'purchaseUnitId',
  516. item.packageDispositionList[0].id
  517. );
  518. this.$set(
  519. parasm,
  520. 'purchaseUnit',
  521. item.packageDispositionList[0].conversionUnit
  522. );
  523. }
  524. this.$set(
  525. parasm,
  526. 'packingSpecification',
  527. item.extField?.packingSpecification
  528. );
  529. this.$set(parasm, 'provenance', item.purchaseOrigins || '');
  530. this.$set(parasm, 'provenanceName', this.getProvenance(item.provenance));
  531. if (idx == -1) {
  532. this.tableList.push(row);
  533. }
  534. });
  535. })
  536. },
  537. onUnload() {
  538. uni.$off('setProduceList')
  539. uni.$off('setTaskName')
  540. uni.$off('setPBomList')
  541. },
  542. watch: {
  543. contractId(val) {
  544. if (val) {
  545. this.btnList = []
  546. }
  547. }
  548. },
  549. methods: {
  550. ...mapActions('dict', ['requestDict']),
  551. openPicker() {
  552. this.$refs.treePicker._show()
  553. },
  554. getGoodsLevelVal(val) {
  555. const goodsLevel = this.levelList.find(item => item.value == val)
  556. return goodsLevel?.text || ''
  557. },
  558. getProvenance(item) {
  559. console.log('getProvenance~~~~~', item)
  560. // try {
  561. // 检查item和provenance是否存在
  562. if (!item) {
  563. return '';
  564. }
  565. let arr = item;
  566. if(!Array.isArray(arr)) {
  567. console.log('arr is not array, convert to array')
  568. arr = arr.split(',');
  569. }
  570. return arr && arr.length ? arr.map((i) => {
  571. return this.purchase_origin.find(p => p.value == i)?.text
  572. }).join(',') : '';
  573. },
  574. changeMultiple(item, index, key, range) {
  575. console.log(item, index)
  576. this.current = item;
  577. this.currentIndex = index;
  578. this.multipleSelectRange = range
  579. this.$refs.multipleSelectRef.open(item, index, key)
  580. },
  581. handleMultipleConfirm(data, key) {
  582. this.$set(this.tableList[this.currentIndex], key, data)
  583. if(key == 'provenance'){
  584. this.$set(this.tableList[this.currentIndex], 'provenanceName', this.getProvenance(data))
  585. }
  586. },
  587. change(e){
  588. console.log('e:',e);
  589. },
  590. settingDate(item, index) {
  591. console.log(item, index)
  592. this.current = item;
  593. this.currentIndex = index;
  594. this.$refs.timePopupRef.open(item, index)
  595. },
  596. handleTimeConfirm(data) {
  597. this.$set(this.tableList[this.currentIndex], 'arrivalBatch', data)
  598. },
  599. add() {
  600. this.currentIndex = -1;
  601. this.current = {};
  602. if (this.isTemporary) {
  603. this.show = true
  604. } else {
  605. uni.navigateTo({
  606. url: '/pages/purchasingManage/components/selectProduce?isAll=' + 1
  607. })
  608. }
  609. },
  610. select({
  611. name
  612. }) {
  613. if (name == '选择物品清单') {
  614. uni.navigateTo({
  615. url: '/pages/purchasingManage/components/selectProduce?isAll=' + 1
  616. })
  617. } else {
  618. this.handlAdd()
  619. }
  620. },
  621. selectProduct(item, index) {
  622. this.current = item;
  623. this.currentIndex = index;
  624. uni.navigateTo({
  625. url: '/pages/purchasingManage/components/selectProduce?isAll=' + 2
  626. })
  627. },
  628. selectTaskName(item, index) {
  629. console.log(item, index)
  630. this.current = item;
  631. this.currentIndex = index;
  632. uni.navigateTo({
  633. url: '/pages/purchasingManage/components/selectTaskName?isAll=' + 2
  634. })
  635. },
  636. // 添加
  637. handlAdd() {
  638. let item = JSON.parse(JSON.stringify(this.defaultForm));
  639. item.key = this.tableList.length + 1;
  640. this.tableList.push(item);
  641. },
  642. init(list) {
  643. if (list) {
  644. this.tableList = JSON.parse(JSON.stringify(list))
  645. // this.getTotalPrice(list)
  646. }
  647. },
  648. getValue() {
  649. return this.tableList
  650. },
  651. del(index) {
  652. this.tableList.splice(index, 1);
  653. },
  654. getByCode() {
  655. const codeS = ['product_model_key', 'product_color_key', 'purchase_origin']
  656. codeS.forEach(async (code) => {
  657. const codeValue = await getByCode(code);
  658. this[code] = codeValue.map(item => {
  659. const key = Object.keys(item)[0]
  660. return {
  661. value: key,
  662. text: item[key]
  663. }
  664. })
  665. console.log(code, this[code])
  666. })
  667. console.log('1111~~~~~~~~~', this.purchase_origin)
  668. },
  669. save() {
  670. uni.$emit('setBusinessOpportunity')
  671. },
  672. //改变数量
  673. changeCount(row, index) {
  674. // this.singleWeightChange(row, index);
  675. // this.getTotalPrice();
  676. this.$set(
  677. this.tableList,
  678. index,
  679. changeCount(row, {
  680. countKey: 'purchaseCount',
  681. unitKey: 'purchaseUnit',
  682. unitIdKey: 'purchaseUnitId'
  683. })
  684. );
  685. this.$forceUpdate();
  686. },
  687. //计算总金额
  688. getTotalPrice(row) {
  689. if (this.tableList.length) {
  690. let sum = 0;
  691. sum = this.getNumTotalPrice();
  692. let allsum = sum.toFixed(2);
  693. this.allPrice = allsum;
  694. if (!row) {
  695. uni.$emit('allsum', allsum)
  696. }
  697. return allsum;
  698. } else {
  699. this.allPrice = 0.0;
  700. if (!row) {
  701. uni.$emit('allsum', allsum)
  702. }
  703. return 0.0;
  704. }
  705. //回显总金额
  706. },
  707. //计算总金额
  708. getNumTotalPrice(sum = 0) {
  709. this.tableList.forEach((r, index) => {
  710. this.$set(
  711. r,
  712. 'discountSinglePrice',
  713. r.singlePrice ? Number(r.singlePrice) : ''
  714. );
  715. if (r.singlePrice && r.totalCount) {
  716. r.totalPrice = this.getAllPrice(r);
  717. r.discountTotalPrice = this.getDiscountTotalPrice(r);
  718. this.$set(this.tableList[index], 'totalPrice', Number(r.totalPrice));
  719. this.$set(
  720. this.tableList[index],
  721. 'discountTotalPrice',
  722. Number(r.discountTotalPrice)
  723. );
  724. sum += Number(r.totalPrice);
  725. } else {
  726. this.$set(r, 'totalPrice', '');
  727. this.$set(r, 'discountTotalPrice', '');
  728. }
  729. });
  730. return isNaN(sum) ? 0 : sum;
  731. },
  732. //计算单重
  733. singleWeightChange(row, index) {
  734. if (row.weightUnit == row.measuringUnit) {
  735. this.$set(this.tableList[index], 'totalWeight', row.totalCount);
  736. } else if (row.totalCount && row.singleWeight) {
  737. this.$set(this.tableList[index], 'totalWeight', (row.singleWeight * row.totalCount).toFixed(2) || 0);
  738. } else {
  739. this.$set(this.tableList[index], 'totalWeight', 0);
  740. }
  741. },
  742. //获取合计
  743. getAllPrice(row) {
  744. let num = Number(row.singlePrice) * Number(row.totalCount);
  745. return isNaN(num) ? '' : num.toFixed(2);
  746. },
  747. //设置优惠后总金额修改产品单价
  748. discountInputByOrder(val) {
  749. //获取优惠金额和总计的差价
  750. this.tableList.forEach((item) => {
  751. if (val === 0) {
  752. item.discountTotalPrice = 0;
  753. item.discountSinglePrice = 0;
  754. return;
  755. }
  756. if (!val) {
  757. item.discountTotalPrice = item.totalPrice;
  758. item.discountSinglePrice = item.singlePrice;
  759. return;
  760. }
  761. //获取折让单价
  762. item.discountSinglePrice = this.getDiscountSinglePrice(item, val);
  763. item.discountTotalPrice = this.getDiscountTotalPrice(item, val);
  764. });
  765. this.$forceUpdate()
  766. },
  767. //获取折让单价
  768. getDiscountSinglePrice(row, val) {
  769. let num =
  770. (Number(val) / Number(this.allPrice)) *
  771. Number(row.singlePrice);
  772. return isNaN(num) ? '' : num;
  773. },
  774. //获取折让合计
  775. getDiscountTotalPrice(row, val) {
  776. let num = Number(row.discountSinglePrice) * Number(row.totalCount);
  777. return isNaN(num) ? '' : num.toFixed(2);
  778. },
  779. //设置客户代号
  780. setCustomerMark(val) {
  781. this.tableList.forEach((item, index) => {
  782. this.$set(this.tableList[index], 'customerMark', val)
  783. })
  784. },
  785. }
  786. }
  787. </script>
  788. <style lang="scss" scoped>
  789. .add {
  790. width: 96rpx;
  791. height: 96rpx;
  792. border-radius: 48rpx;
  793. background: #3c9cff;
  794. position: fixed;
  795. bottom: 100rpx;
  796. right: 24rpx;
  797. display: flex;
  798. align-items: center;
  799. justify-content: center;
  800. z-index: 99;
  801. }
  802. .slot-box {
  803. display: flex;
  804. }
  805. .footerButton {
  806. width: 100%;
  807. height: 84rpx;
  808. display: flex;
  809. position: fixed;
  810. bottom: 0;
  811. z-index: 10;
  812. /deep/.u-button {
  813. height: 100%;
  814. }
  815. >view {
  816. flex: 1;
  817. }
  818. }
  819. /deep/.u-swipe-action-item__right__button__wrapper {
  820. background-color: #f56c6c !important;
  821. }
  822. </style>