produceList.vue 23 KB

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