add.js 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 编辑履历:
  6. * 作者 日期 版本 修改内容
  7. * 王英杰 2024-1-24 1.00 新建商品档案
  8. *******************************************************************************/
  9. const mixins = require('@/mixins/index.js')
  10. const app = getApp()
  11. const util = require('@/utils/util.js')
  12. const Constants = require('@/utils/Constants')
  13. import Dialog from '@/dist/dialog/dialog.js';
  14. Page({
  15. mixins: [mixins],
  16. /**
  17. * 页面的初始数据
  18. */
  19. data: {
  20. // gradeCode: app.globalData.company.gradeCode, //判断版本的 ( 标准还是专业)
  21. buttonList: [{
  22. name: 'merge',
  23. title: mixins.$t("save"), //'保存'
  24. }],
  25. table: Constants.tables.goodsSku,
  26. cardList: [], //不在这定义 在 loadinit定义
  27. contentObj: {
  28. main: [{ //商品型号
  29. code: 'skuModel',
  30. type: 'textarea',
  31. title: mixins.$t("skuModel"),
  32. required: true,
  33. }, { //商品名称
  34. code: 'skuName',
  35. type: 'textarea',
  36. title: mixins.$t("skuName"),
  37. }, {
  38. code: 'skuImages',
  39. name: mixins.$t("commodityPicture"), //商品图片
  40. type: 'uploader',
  41. },
  42. ],
  43. goods: [{ //商品品牌
  44. code: 'brandId',
  45. name: 'brandName',
  46. title: mixins.$t("goodsBrand"),
  47. type: 'choose',
  48. urlKey: 'goodsBrand',
  49. required: true,
  50. },
  51. { //商品种类
  52. code: 'categoryId',
  53. name: 'catName',
  54. title: mixins.$t("goodsCategory"),
  55. type: 'choose',
  56. urlKey: 'goodsCategory',
  57. required: true,
  58. }, { //商品系列
  59. code: 'seriesId',
  60. name: 'seriesName',
  61. title: mixins.$t("goodsSeries"),
  62. type: 'choose',
  63. urlKey: 'goodsSeries',
  64. }, { //商品规格
  65. code: 'skuSpec',
  66. name: 'skuSpec',
  67. type: 'textarea',
  68. required: true,
  69. title: mixins.$t("sukSpec"),
  70. }
  71. ],
  72. unit: [{ //基本单位
  73. code: 'unitId',
  74. name: 'unitName',
  75. title: mixins.$t("unit"),
  76. type: 'choose',
  77. urlKey: 'unit',
  78. required: true,
  79. clear: false,
  80. }, { //辅助单位标识
  81. type: 'switch',
  82. title: mixins.$t("subUnitId"),
  83. code: 'flgSubUnit',
  84. }, { //包装单位
  85. code: 'subUnitId',
  86. name: 'subUnitName',
  87. title: mixins.$t("packageUnit"),
  88. type: 'choose',
  89. urlKey: 'unit',
  90. required: true,
  91. readonly: true,
  92. }, { //包装
  93. code: 'packBox',
  94. title: mixins.$t("package"),
  95. type: 'number',
  96. sign: "",
  97. digits: 0,
  98. required: true,
  99. readonly: true,
  100. },
  101. {
  102. code: 'calculationFormula',
  103. type: 'textarea',
  104. title: mixins.$t("calculationFormula"),
  105. readonly: true,
  106. }
  107. ],
  108. warehouse: [{ //期初库存标识
  109. type: 'switch',
  110. title: mixins.$t("openingInv"),
  111. code: 'flgOpeningInv',
  112. }, ],
  113. price: [{ //期初库存标识
  114. type: 'switch',
  115. title: mixins.$t("flgPrice"),
  116. code: 'flgPrice',
  117. }, { //采购价
  118. tip: mixins.$t("purchasePricetip"),
  119. code: 'pricePurchase',
  120. type: 'number',
  121. title: mixins.$t("purchasePrice"),
  122. required: true,
  123. }, { //零售价
  124. tip: mixins.$t("retailPricetip"),
  125. code: 'priceStandard',
  126. type: 'number',
  127. title: mixins.$t("retailPrice"),
  128. required: true,
  129. }, { //批发价
  130. tip: mixins.$t("wholesalePricetip"),
  131. code: 'priceWholesale',
  132. type: 'number',
  133. title: mixins.$t("wholesalePrice"),
  134. required: true,
  135. }, { //销售限价
  136. tip: mixins.$t("SaleSPriceLimittip"),
  137. code: 'priceLimited',
  138. type: 'number',
  139. title: mixins.$t("SaleSPriceLimit"),
  140. required: true,
  141. }, { //其他价
  142. tip: mixins.$t("otherPriceLimittip"),
  143. code: 'priceOther',
  144. type: 'number',
  145. title: mixins.$t("otherPriceLimit"),
  146. required: true,
  147. }, ],
  148. // warning: [{ // 预警信息
  149. // type: 'textarea',
  150. // title: mixins.$t("warningLowerLimit"),
  151. // code: 'warningLowerLimit',
  152. // },{
  153. // type: 'textarea',
  154. // title: mixins.$t("warningUpperLimit"),
  155. // code: 'warningUpperLimit',
  156. // }],
  157. other: [{
  158. code: 'remarks',
  159. type: 'textarea',
  160. title: mixins.$t("remarks"),
  161. }]
  162. },
  163. popContentBox: [],
  164. // 路由
  165. routeObjName: 'goodsSku',
  166. // 包装小数位
  167. packBoxDigits: 0,
  168. },
  169. /**
  170. * @desc : 数量改变事件
  171. * @date : 2024/2/1 15:49
  172. * @author : 王英杰
  173. */
  174. changeStep(e) {
  175. let key = e.detail.key
  176. let value = e.detail.value
  177. let dataItem = JSON.parse(this.data.dataItem)
  178. dataItem[key] = value
  179. this.setData({
  180. dataItem: JSON.stringify(dataItem)
  181. })
  182. },
  183. /**
  184. * @desc : dk-form 里 str的点击回调 的输入回调
  185. * @date : 2024/2/1 15:49
  186. * @author : 王英杰
  187. */
  188. openStr(e) {
  189. let code = e.detail.code
  190. const readonly = e.detail.readonly
  191. if (code == "packageBox" && !readonly) { //点击包装数量
  192. let formData = JSON.parse(this.data.formData)
  193. if (formData.unitId && formData.subUnitId && formData.packBox) {
  194. let dataItem = this.data.dataItem ? JSON.parse(this.data.dataItem) : {}
  195. dataItem['box'] = formData.box || 0
  196. dataItem['piece'] = formData.piece || 0
  197. dataItem.packageBox = formData.packageBox
  198. let popContentBox = [{
  199. code: 'box',
  200. type: 'step',
  201. title: formData.subUnitName,
  202. required: true
  203. },
  204. {
  205. code: 'piece',
  206. type: 'step',
  207. title: formData.unitName,
  208. required: true
  209. },
  210. ]
  211. this.setData({
  212. showPopBox: true,
  213. dataItem: JSON.stringify(dataItem),
  214. popContentBox: popContentBox
  215. })
  216. } else {
  217. util.showToast('请先输入基本单位、包装单位、包装');
  218. }
  219. }
  220. },
  221. /**
  222. * @desc : 商品确认事件--箱片的确认
  223. * @date : 2024/2/1 15:49
  224. * @author : 王英杰
  225. */
  226. editItemsBox(e) {
  227. let dataItem = JSON.parse(this.data.dataItem)
  228. let formData = JSON.parse(this.data.formData)
  229. formData['box'] = dataItem['box']
  230. formData['piece'] = dataItem['piece']
  231. formData['intoQty'] = Number(dataItem['box']) * Number(formData['packBox']) + Number(dataItem['piece'])
  232. formData.packageBox = dataItem['box'] + formData.subUnitName + dataItem['piece'] + formData.unitName
  233. this.setData({
  234. formData: JSON.stringify(formData)
  235. })
  236. },
  237. /**
  238. * @desc : dk-form 里 dk-number-input 的输入回调
  239. * @date : 2024/2/1 15:49
  240. * @author : 王英杰
  241. */
  242. triggerBindBlur(e) {
  243. let code = e.detail.code
  244. let formData = JSON.parse(this.data.formData)
  245. formData[code] = formData[code] ?formData[code]:0
  246. if (code == "packBox") { //包装
  247. if (formData.intoQty || formData.packageBox) {
  248. //提示
  249. Dialog.confirm({
  250. message: '修改包装将清空期初数量、包装数量',
  251. }).then(() => {
  252. formData.intoQty = null
  253. formData.packageBox = null
  254. formData.box = null
  255. formData.piece = null
  256. formData["packBox_"] = formData["packBox"]
  257. if (formData.packBox && formData.unitName && formData.subUnitName) { //选了辅助计量单位 正好 包装也有值 那么直接给出公式
  258. formData.calculationFormula = formData.packBox + formData.unitName + '= 1' + formData.subUnitName
  259. }
  260. this.setData({
  261. formData: JSON.stringify(formData)
  262. })
  263. }).catch(() => {
  264. formData["packBox"] = formData["packBox_"]
  265. this.setData({
  266. formData: JSON.stringify(formData)
  267. })
  268. });
  269. } else {
  270. if (formData.packBox && formData.unitName && formData.subUnitName) { //选了辅助计量单位 正好 包装也有值 那么直接给出公式
  271. formData.calculationFormula = formData.packBox + formData.unitName + '= 1' + formData.subUnitName
  272. }
  273. formData["packBox_"] = formData["packBox"]
  274. }
  275. }
  276. if (code == "intoQty" && formData.flgSubUnit) { //期初数量
  277. if (formData.unitId && formData.subUnitId && formData.packBox) {
  278. formData['box'] = parseInt(formData['intoQty'] / formData['packBox'])
  279. formData['piece'] = parseFloat(Number(formData['intoQty'] % formData['packBox']).toFixed(formData.decimalPlaces));
  280. formData.packageBox = formData['box'] + formData.subUnitName + formData['piece'] + formData.unitName
  281. } else {
  282. formData['intoQty'] = undefined
  283. util.showToast('请先输入基本单位、包装单位、包装');
  284. }
  285. }
  286. this.setData({
  287. formData: JSON.stringify(formData)
  288. })
  289. },
  290. /**
  291. * @desc : dk-form 里 Switch 的切换回调
  292. * @date : 2024/2/1 15:49
  293. * @author : 王英杰
  294. */
  295. onSwitchChange(e) {
  296. let code = e.detail.code
  297. let checkFlag = !e.detail.checkFlag
  298. let contentObj = this.data.contentObj
  299. let formData = JSON.parse(this.data.formData)
  300. if (code == "flgSubUnit") { //辅助单位
  301. if (checkFlag) {
  302. let formData = JSON.parse(this.data.formData)
  303. // 当未选择基本单位时不能打开辅助单位开关
  304. if (!formData.unitId) {
  305. formData.flgSubUnit = false
  306. util.showToast('请先选择基本单位');
  307. this.setData({
  308. formData: JSON.stringify(formData)
  309. })
  310. return
  311. }
  312. contentObj.unit = [{ //基本单位
  313. code: 'unitId',
  314. name: 'unitName',
  315. title: mixins.$t("unit"),
  316. type: 'choose',
  317. urlKey: 'unit',
  318. required: true,
  319. clear: false,
  320. }, { //辅助单位标识
  321. type: 'switch',
  322. title: mixins.$t("subUnitId"),
  323. code: 'flgSubUnit',
  324. }, { //包装单位
  325. code: 'subUnitId',
  326. name: 'subUnitName',
  327. title: mixins.$t("packageUnit"),
  328. type: 'choose',
  329. urlKey: 'unit',
  330. required: checkFlag,
  331. }, { //包装
  332. code: 'packBox',
  333. title: mixins.$t("package"),
  334. type: 'number',
  335. sign: "",
  336. // todo
  337. digits: this.packBoxDigits,
  338. required: checkFlag,
  339. },
  340. {
  341. code: 'calculationFormula',
  342. type: 'textarea',
  343. title: mixins.$t("calculationFormula"),
  344. readonly: true,
  345. }
  346. ]
  347. } else {
  348. let formDataJson = JSON.parse(this.data.formData)
  349. if (formDataJson) {
  350. ['subUnitName', 'calculationFormula', 'packBox'].forEach(key => {
  351. if (formDataJson.hasOwnProperty(key)) {
  352. delete formDataJson[key];
  353. }
  354. });
  355. }
  356. this.setData({
  357. formData: JSON.stringify(formDataJson)
  358. })
  359. contentObj.unit = [{ //基本单位
  360. code: 'unitId',
  361. name: 'unitName',
  362. title: mixins.$t("unit"),
  363. type: 'choose',
  364. urlKey: 'unit',
  365. required: true,
  366. clear: false,
  367. }, { //辅助单位标识
  368. type: 'switch',
  369. title: mixins.$t("subUnitId"),
  370. code: 'flgSubUnit',
  371. }, ]
  372. }
  373. // 解决 (商品档案,如果先点开期初库存,然后再点开辅助单位,那么包装数量就不会显示出来) 问题
  374. if (formData.flgOpeningInv) { //开了期初库存
  375. if (checkFlag) { //开了辅助单位
  376. contentObj.warehouse = [{ //期初库存标识
  377. type: 'switch',
  378. title: mixins.$t("openingInv"),
  379. code: 'flgOpeningInv',
  380. }, { //仓库名称
  381. code: 'whId',
  382. name: 'whName',
  383. title: mixins.$t("whName"),
  384. type: 'choose',
  385. urlKey: 'openingInventory',
  386. required: checkFlag,
  387. },
  388. { //库存批号
  389. code: 'nonStdCode',
  390. type: 'textarea',
  391. title: mixins.$t("iinventoryBatchNumber"),
  392. required: checkFlag,
  393. tip: mixins.$t('tipPop'),
  394. },
  395. { //期初数量
  396. code: 'intoQty',
  397. type: 'number',
  398. sign: "",
  399. digits: formData.decimalPlaces,
  400. title: mixins.$t("openingInventoryQty"),
  401. required: checkFlag,
  402. },
  403. {
  404. code: 'packageBox',
  405. type: 'str',
  406. title: mixins.$t("packageBox"),
  407. required: checkFlag,
  408. readonly: true,
  409. },
  410. { //期初成本价
  411. code: 'priceInto',
  412. type: 'number',
  413. title: mixins.$t("iinitialCostPrice"),
  414. required: checkFlag,
  415. },
  416. ]
  417. } else { //没开辅助单位
  418. contentObj.warehouse = [{ //期初库存标识
  419. type: 'switch',
  420. title: mixins.$t("openingInv"),
  421. code: 'flgOpeningInv',
  422. }, { //仓库名称
  423. code: 'whId',
  424. name: 'whName',
  425. title: mixins.$t("whName"),
  426. type: 'choose',
  427. urlKey: 'openingInventory',
  428. required: checkFlag,
  429. },
  430. { //库存批号
  431. code: 'nonStdCode',
  432. type: 'textarea',
  433. title: mixins.$t("iinventoryBatchNumber"),
  434. required: checkFlag,
  435. tip: mixins.$t('tipPop'),
  436. },
  437. { //期初数量
  438. code: 'intoQty',
  439. type: 'number',
  440. sign: "",
  441. digits: formData.decimalPlaces,
  442. title: mixins.$t("openingInventoryQty"),
  443. required: checkFlag,
  444. },
  445. { //期初成本价
  446. code: 'priceInto',
  447. type: 'number',
  448. title: mixins.$t("iinitialCostPrice"),
  449. required: checkFlag,
  450. },
  451. ]
  452. }
  453. }
  454. } else if (code == "flgOpeningInv") { //期初库存标识
  455. if (checkFlag) {
  456. let formData = JSON.parse(this.data.formData)
  457. //打开期初库存的时候 要先判断 需要先选择基本单位
  458. if (!formData.unitId) {
  459. formData.flgOpeningInv = false
  460. util.showToast('请先选择基本单位');
  461. this.setData({
  462. formData: JSON.stringify(formData)
  463. })
  464. return
  465. }
  466. if (formData.flgSubUnit) { //开了辅助单位
  467. contentObj.warehouse = [{ //期初库存标识
  468. type: 'switch',
  469. title: mixins.$t("openingInv"),
  470. code: 'flgOpeningInv',
  471. }, { //仓库名称
  472. code: 'whId',
  473. name: 'whName',
  474. title: mixins.$t("whName"),
  475. type: 'choose',
  476. urlKey: 'openingInventory',
  477. required: checkFlag,
  478. },
  479. { //库存批号
  480. code: 'nonStdCode',
  481. type: 'textarea',
  482. title: mixins.$t("iinventoryBatchNumber"),
  483. required: checkFlag,
  484. tip: mixins.$t('tipPop'),
  485. },
  486. { //期初数量
  487. code: 'intoQty',
  488. type: 'number',
  489. sign: "",
  490. digits: formData.decimalPlaces,
  491. title: mixins.$t("openingInventoryQty"),
  492. required: checkFlag,
  493. },
  494. {
  495. code: 'packageBox',
  496. type: 'str',
  497. title: mixins.$t("packageBox"),
  498. required: checkFlag,
  499. readonly: true,
  500. },
  501. { //期初成本价
  502. code: 'priceInto',
  503. type: 'number',
  504. title: mixins.$t("iinitialCostPrice"),
  505. required: checkFlag,
  506. },
  507. ]
  508. } else { //没开辅助单位
  509. contentObj.warehouse = [{ //期初库存标识
  510. type: 'switch',
  511. title: mixins.$t("openingInv"),
  512. code: 'flgOpeningInv',
  513. }, { //仓库名称
  514. code: 'whId',
  515. name: 'whName',
  516. title: mixins.$t("whName"),
  517. type: 'choose',
  518. urlKey: 'openingInventory',
  519. required: checkFlag,
  520. },
  521. { //库存批号
  522. code: 'nonStdCode',
  523. type: 'textarea',
  524. title: mixins.$t("iinventoryBatchNumber"),
  525. required: checkFlag,
  526. tip: mixins.$t('tipPop'),
  527. },
  528. { //期初数量
  529. code: 'intoQty',
  530. type: 'number',
  531. sign: "",
  532. digits: formData.decimalPlaces,
  533. title: mixins.$t("openingInventoryQty"),
  534. required: checkFlag,
  535. },
  536. { //期初成本价
  537. code: 'priceInto',
  538. type: 'number',
  539. title: mixins.$t("iinitialCostPrice"),
  540. required: checkFlag,
  541. },
  542. ]
  543. }
  544. } else {
  545. /**
  546. * 关闭初期按钮后删除对应的初期数据
  547. * @author 刘尧
  548. * @data 2024.06.04
  549. */
  550. let formData = JSON.parse(this.data.formData)
  551. if (formData) {
  552. ['packageBox', 'priceInto', 'intoQty', 'nonStdCode', 'whName', 'whId'].forEach(key => {
  553. if (formData.hasOwnProperty(key)) {
  554. delete formData[key];
  555. }
  556. });
  557. }
  558. this.setData({
  559. formData: JSON.stringify(formData)
  560. })
  561. contentObj.warehouse = [{ //期初库存标识
  562. type: 'switch',
  563. title: mixins.$t("openingInv"),
  564. code: 'flgOpeningInv',
  565. }, ]
  566. }
  567. } else if (code == "flgPrice") { //期初库存标识
  568. if (checkFlag) {
  569. contentObj.price = [{ //期初库存标识
  570. type: 'switch',
  571. title: mixins.$t("flgPrice"),
  572. code: 'flgPrice',
  573. }, { //采购价
  574. tip: mixins.$t("purchasePricetip"),
  575. code: 'pricePurchase',
  576. type: 'number',
  577. title: mixins.$t("purchasePrice"),
  578. required: checkFlag,
  579. }, { //零售价
  580. tip: mixins.$t("retailPricetip"),
  581. code: 'priceStandard',
  582. type: 'number',
  583. title: mixins.$t("retailPrice"),
  584. required: checkFlag,
  585. }, { //批发价
  586. tip: mixins.$t("wholesalePricetip"),
  587. code: 'priceWholesale',
  588. type: 'number',
  589. title: mixins.$t("wholesalePrice"),
  590. required: checkFlag,
  591. }, { //销售限价
  592. tip: mixins.$t("SaleSPriceLimittip"),
  593. code: 'priceLimited',
  594. type: 'number',
  595. title: mixins.$t("SaleSPriceLimit"),
  596. required: checkFlag,
  597. }, { //其他价
  598. tip: mixins.$t("otherPriceLimittip"),
  599. code: 'priceOther',
  600. type: 'number',
  601. title: mixins.$t("otherPriceLimit"),
  602. required: checkFlag,
  603. }, ]
  604. } else {
  605. contentObj.price = [{ //期初库存标识
  606. type: 'switch',
  607. title: mixins.$t("flgPrice"),
  608. code: 'flgPrice',
  609. }, ]
  610. }
  611. }
  612. this.setData({
  613. contentObj: contentObj
  614. })
  615. },
  616. onShow() {
  617. this.dialogShowChooseData();
  618. },
  619. /**
  620. * @desc : 因为chooseData 的执行顺序要高于onshow 且 chooseData无法弹 dialog 所以在onshow执行
  621. * @date : 2024/2/1 15:49
  622. * @author : 王英杰
  623. */
  624. dialogShowChooseData() {
  625. if (!this.data.handledata) {
  626. return
  627. }
  628. // todo
  629. this.setData({
  630. handledata: false
  631. })
  632. let formData = JSON.parse(this.data.formData)
  633. let data = this.data.chooseUnitData
  634. let Dialog_message = null
  635. let code = this.data.chooseDataCode
  636. if (code == "unitId") { //计量单位
  637. formData.intoQty = null
  638. formData.packBox = null
  639. formData.subUnitId = null
  640. formData.subUnitName = null
  641. formData.packageBox = null
  642. formData.box = null
  643. formData.piece = null
  644. // 当重新选择基本单位后清空公式 刘尧 2024.5.30
  645. formData.calculationFormula = null
  646. Dialog_message = '更换基础单位将清空包装单位、期初数量、包装、包装数量'
  647. }
  648. if (code == "subUnitId") { //包装单位
  649. formData.intoQty = null
  650. formData.packageBox = null
  651. formData.box = null
  652. formData.piece = null
  653. Dialog_message = '更换包装单位将清空期初数量、包装数量'
  654. }
  655. //提示
  656. Dialog.confirm({
  657. message: Dialog_message,
  658. }).then(() => {
  659. this.handleChooseDataUnit(formData, data, code)
  660. }).catch(() => {});
  661. },
  662. /**
  663. * @desc : 选择页面跳转回调事件
  664. * @date : 2024/2/1 15:49
  665. * @author : 王英杰
  666. */
  667. chooseData(e) {
  668. let formData = JSON.parse(this.data.formData)
  669. let code = e.detail.code
  670. let data = e.detail.data.data
  671. if (code == "brandId") { //商品品牌
  672. formData.brandId = data.id
  673. formData.brandName = data.name
  674. }
  675. if (code == "categoryId") { //商品种类
  676. formData.categoryId = data.id
  677. formData.catName = data.name
  678. }
  679. if (code == "unitId") { //计量单位
  680. //当期初数量有值的时候 弹提示是否清除
  681. if (formData.intoQty || formData.packBox || formData.subUnitId || formData.packageBox) { //在onshow执行 这里无法弹出dialog
  682. this.setData({
  683. chooseUnitData: data,
  684. handledata: true,
  685. chooseDataCode: code
  686. })
  687. } else {
  688. this.handleChooseDataUnit(formData, data, code)
  689. }
  690. }
  691. if (code == "subUnitId") { //辅助计量单位
  692. if (data.id == formData.unitId) {
  693. setTimeout(() => {
  694. util.showToast('包装单位不能等于基本单位');
  695. }, 1000)
  696. return
  697. }
  698. if (formData.intoQty || formData.packageBox) { //在onshow执行 这里无法弹出dialog
  699. this.setData({
  700. chooseUnitData: data,
  701. handledata: true,
  702. chooseDataCode: code
  703. })
  704. } else {
  705. this.handleChooseDataUnit(formData, data, code)
  706. }
  707. if (formData.packBox && formData.unitName && formData.subUnitName) { //选了辅助计量单位 正好 包装也有值 那么直接给出公式
  708. formData.calculationFormula = formData.packBox + formData.unitName + '= 1' + formData.subUnitName
  709. }
  710. }
  711. if (code == "seriesId") { //商品系列
  712. formData.seriesId = data.id
  713. formData.seriesName = data.name
  714. }
  715. if (code == "whId") { //仓库名称
  716. formData.whId = data.id
  717. formData.whName = data.name
  718. }
  719. this.setData({
  720. formData: JSON.stringify(formData)
  721. })
  722. },
  723. /**
  724. * @desc : 处理 选择页面回来的 基本单位
  725. * @date : 2024/2/1 15:49
  726. * @author : 王英杰
  727. */
  728. handleChooseDataUnit(formData, data, code) {
  729. if (code == "unitId") {
  730. formData.unitId = data.id
  731. formData.unitName = data.name
  732. formData.decimalPlaces = data.decimalPlaces
  733. let dataItem = this.data.dataItem ? JSON.parse(this.data.dataItem) : {}
  734. dataItem.decimalPlaces = data.decimalPlaces
  735. if (formData.packBox && formData.unitName && formData.subUnitName) { //选了辅助计量单位 正好 包装也有值 那么直接给出公式
  736. formData.calculationFormula = formData.packBox + formData.unitName + '= 1' + formData.subUnitName
  737. }
  738. let contentObj = this.data.contentObj
  739. let packBoxDigits = formData.decimalPlaces
  740. if (contentObj.warehouse.length > 0) {
  741. // 遍历 contentObj.warehouse 数组
  742. for (let i = 0; i < contentObj.warehouse.length; i++) {
  743. // 检查当前对象的 code 是否为 'intoQty'
  744. if (contentObj.warehouse[i].code === 'intoQty') { //期初数量
  745. // 如果是,则修改其 digits 属性
  746. contentObj.warehouse[i].digits = formData.decimalPlaces;
  747. contentObj.warehouse[i].readonly = false;
  748. // 找到后,可以跳出循环(如果确定只有一个匹配项)
  749. break;
  750. }
  751. }
  752. }
  753. if (contentObj.unit.length > 0) {
  754. // 遍历 contentObj.unit 数组
  755. for (let i = 0; i < contentObj.unit.length; i++) {
  756. // 检查当前对象的 code 是否为 'packBox'
  757. if (contentObj.unit[i].code === 'packBox') { //包装
  758. // 如果是,则修改其 digits 属性
  759. contentObj.unit[i].digits = formData.decimalPlaces;
  760. contentObj.unit[i].readonly = false;
  761. continue
  762. }
  763. if (contentObj.unit[i].code === 'subUnitId') { //包装单位
  764. contentObj.unit[i].readonly = false;
  765. continue
  766. }
  767. }
  768. }
  769. this.setData({
  770. packBoxDigits: packBoxDigits,
  771. contentObj: contentObj,
  772. formData: JSON.stringify(formData),
  773. dataItem: JSON.stringify(dataItem)
  774. })
  775. }
  776. if (code == "subUnitId") {
  777. formData.subUnitId = data.id
  778. formData.subUnitName = data.name
  779. this.setData({
  780. formData: JSON.stringify(formData),
  781. })
  782. }
  783. return
  784. },
  785. /**
  786. * @desc : 保存数据服务--校验
  787. * @date : 2024/2/1 15:49
  788. * @author : 王英杰
  789. */
  790. validData() {
  791. console.log('validData2');
  792. let formData = JSON.parse(this.data.formData)
  793. if (!formData.flgSubUnit) { //辅助单位标识未勾选 不存包装单位 包装
  794. delete formData.subUnitId
  795. delete formData.subUnitName
  796. delete formData.packBox
  797. }
  798. //编辑的时候 就不用删除了 因为不允许修改
  799. if ((!formData.flgOpeningInv) && this.data.formMode !== Constants.formMode.edit) { //期初库存标识未勾选 不存仓库名称 色号 起初数量 期初成本价
  800. delete formData.whId
  801. delete formData.whName
  802. delete formData.nonStdCode
  803. delete formData.priceInto
  804. }
  805. if (!formData.flgPrice) { //价格体系标识未勾选 不存采购价 零售价 批发价 销售限价 其他价
  806. delete formData.pricePurchase
  807. delete formData.priceStandard
  808. delete formData.priceWholesale
  809. delete formData.priceLimited
  810. delete formData.priceOther
  811. }
  812. this.setData({
  813. formData: JSON.stringify(formData)
  814. })
  815. return true
  816. },
  817. // 设置保存参数
  818. setParams(params) {
  819. let saveData = JSON.parse(this.data.formData)
  820. // 修改之后的 值
  821. params = Object.assign({}, params, saveData);
  822. params.serviceCategories = (params.serviceCategories && params.serviceCategories.length > 0) ? params.serviceCategories.split(',') : []
  823. params.skuImages = params.annexPaths
  824. params.orgId = app.globalData.user.orgId
  825. return params
  826. },
  827. /**
  828. * @desc : 保存数据服务
  829. * @date : 2024/2/1 15:49
  830. * @author : 王英杰
  831. */
  832. saveData() {
  833. let that = this
  834. if (this.data.formMode == Constants.formMode.edit) { //编辑接口
  835. return this.excute(this.data.service, this.data.service.update, this.data.params)
  836. } else { //新建接口
  837. let excute = this.excute(this.data.service, this.data.service.insert, this.data.params)
  838. excute.then(res => {
  839. // 增加包装;数字类型正整数,默认1
  840. let formData = {}
  841. let contentObj = this.data.contentObj
  842. formData.flgPrice = true
  843. formData.flgOpeningInv = false
  844. formData.flgSubUnit = true
  845. that.setData({
  846. formData: JSON.stringify(formData),
  847. loading: false,
  848. contentObj: {
  849. main: [{ //商品型号
  850. code: 'skuModel',
  851. type: 'textarea',
  852. title: mixins.$t("skuModel"),
  853. required: true,
  854. }, { //商品名称
  855. code: 'skuName',
  856. type: 'textarea',
  857. title: mixins.$t("skuName"),
  858. }, {
  859. code: 'skuImages',
  860. name: mixins.$t("commodityPicture"), //商品图片
  861. type: 'uploader',
  862. },
  863. ],
  864. goods: [{ //商品品牌
  865. code: 'brandId',
  866. name: 'brandName',
  867. title: mixins.$t("goodsBrand"),
  868. type: 'choose',
  869. urlKey: 'goodsBrand',
  870. required: true,
  871. },
  872. { //商品种类
  873. code: 'categoryId',
  874. name: 'catName',
  875. title: mixins.$t("goodsCategory"),
  876. type: 'choose',
  877. urlKey: 'goodsCategory',
  878. required: true,
  879. }, { //商品系列
  880. code: 'seriesId',
  881. name: 'seriesName',
  882. title: mixins.$t("goodsSeries"),
  883. type: 'choose',
  884. urlKey: 'goodsSeries',
  885. }, { //商品规格
  886. code: 'skuSpec',
  887. name: 'skuSpec',
  888. type: 'textarea',
  889. required: true,
  890. title: mixins.$t("sukSpec"),
  891. }
  892. ],
  893. unit: [{ //基本单位
  894. code: 'unitId',
  895. name: 'unitName',
  896. title: mixins.$t("unit"),
  897. type: 'choose',
  898. urlKey: 'unit',
  899. required: true,
  900. clear: false,
  901. }, { //辅助单位标识
  902. type: 'switch',
  903. title: mixins.$t("subUnitId"),
  904. code: 'flgSubUnit',
  905. }
  906. ],
  907. warehouse: [{ //期初库存标识
  908. type: 'switch',
  909. title: mixins.$t("openingInv"),
  910. code: 'flgOpeningInv',
  911. }, ],
  912. price: [{ //期初库存标识
  913. type: 'switch',
  914. title: mixins.$t("flgPrice"),
  915. code: 'flgPrice',
  916. }, { //采购价
  917. tip: mixins.$t("purchasePricetip"),
  918. code: 'pricePurchase',
  919. type: 'number',
  920. title: mixins.$t("purchasePrice"),
  921. required: true,
  922. }, { //零售价
  923. tip: mixins.$t("retailPricetip"),
  924. code: 'priceStandard',
  925. type: 'number',
  926. title: mixins.$t("retailPrice"),
  927. required: true,
  928. }, { //批发价
  929. tip: mixins.$t("wholesalePricetip"),
  930. code: 'priceWholesale',
  931. type: 'number',
  932. title: mixins.$t("wholesalePrice"),
  933. required: true,
  934. }, { //销售限价
  935. tip: mixins.$t("SaleSPriceLimittip"),
  936. code: 'priceLimited',
  937. type: 'number',
  938. title: mixins.$t("SaleSPriceLimit"),
  939. required: true,
  940. }, { //其他价
  941. tip: mixins.$t("otherPriceLimittip"),
  942. code: 'priceOther',
  943. type: 'number',
  944. title: mixins.$t("otherPriceLimit"),
  945. required: true,
  946. }, ],
  947. other: [{
  948. code: 'remarks',
  949. type: 'textarea',
  950. title: mixins.$t("remarks"),
  951. }]
  952. }
  953. })
  954. })
  955. return excute;
  956. }
  957. },
  958. /**
  959. * @desc : 处理保存后续事件
  960. * @date : 2024/2/1 15:49
  961. * @author : 姜永辉
  962. */
  963. handleSaveData() {
  964. //购物车跳转来的,新建完毕直接回到选择界面
  965. if (this.data.formType == Constants.formType.shopping) {
  966. // var pages = getCurrentPages();
  967. // var prevPage = pages[pages.length - 2]; //上一个页面
  968. // prevPage.setData({
  969. // refreshByAdd: true
  970. // })
  971. // 给父页面传递数据
  972. const eventChannel = this.getOpenerEventChannel();
  973. eventChannel.emit('refresh', {
  974. id: 1
  975. })
  976. setTimeout(() => {
  977. wx.navigateBack({
  978. delta: 1
  979. });
  980. }, 200)
  981. }
  982. //新手引导过来,需要返回
  983. if (this.data.formReturnMode == Constants.formReturnMode.beginnerGuide) {
  984. const eventChannel = this.getOpenerEventChannel();
  985. eventChannel.emit('refresh', {
  986. id: 1
  987. })
  988. setTimeout(() => {
  989. wx.navigateBack({
  990. delta: 1
  991. });
  992. }, 200)
  993. }
  994. },
  995. /**
  996. * @desc : 页面加载数据方法
  997. * @date : 2024/2/1 15:49
  998. * @author : 王英杰
  999. */
  1000. loadInit() {
  1001. //标准版商品档案新建、编辑、详情不展示价格体系
  1002. if (this.data.gradeCode == Constants.gradeCode.STD) { //标准版
  1003. this.setData({
  1004. cardList: ['main', 'goods', "unit", "warehouse", 'other'],
  1005. })
  1006. } else {
  1007. this.setData({
  1008. cardList: ['main', 'goods', "unit", "warehouse", 'price', 'other'],
  1009. })
  1010. }
  1011. if (this.data.formMode == Constants.formMode.edit) {
  1012. wx.setNavigationBarTitle({
  1013. title: mixins.$t('editGoodsSuk'),
  1014. })
  1015. } else {
  1016. // 增加包装;数字类型正整数,默认1
  1017. let formData = JSON.parse(this.data.formData) || {}
  1018. formData.flgPrice = true
  1019. formData.flgOpeningInv = false
  1020. formData.flgSubUnit = false
  1021. formData.pricePurchase = 0
  1022. formData.priceStandard = 0
  1023. formData.priceWholesale = 0
  1024. formData.priceLimited = 0
  1025. formData.priceOther = 0
  1026. // 获取表单总信息
  1027. let contentObj = this.data.contentObj
  1028. // 当页面初始化的时候 将其他内容隐藏
  1029. contentObj.unit = [{ //基本单位
  1030. code: 'unitId',
  1031. name: 'unitName',
  1032. title: mixins.$t("unit"),
  1033. type: 'choose',
  1034. urlKey: 'unit',
  1035. required: true,
  1036. clear: false,
  1037. }, { //辅助单位标识
  1038. type: 'switch',
  1039. title: mixins.$t("subUnitId"),
  1040. code: 'flgSubUnit',
  1041. }, ]
  1042. this.setData({
  1043. formData: JSON.stringify(formData),
  1044. contentObj: contentObj
  1045. })
  1046. wx.setNavigationBarTitle({
  1047. title: mixins.$t('addGoodsSuk'),
  1048. })
  1049. }
  1050. },
  1051. /**
  1052. * @desc : 给表单赋值
  1053. * @date : 2024/2/1 15:49
  1054. * @author : 王英杰
  1055. */
  1056. setValuesByEdit(data) {
  1057. // data.serviceCategories = (data.serviceCategories && data.serviceCategories.length > 0) ? data.serviceCategories.join(',') : undefined
  1058. data.annexPaths = data.skuImages
  1059. data.onlyCode = data.skuCode
  1060. let contentObj = this.data.contentObj
  1061. // 我们要添加的新对象是 编码 新建的时候没有 编辑的时候添加
  1062. contentObj.main = [{ //唯一编码
  1063. code: 'onlyCode',
  1064. type: 'textarea',
  1065. title: mixins.$t("onlyCode"),
  1066. readonly: true
  1067. }, { //商品型号
  1068. code: 'skuModel',
  1069. type: 'textarea',
  1070. title: mixins.$t("skuModel"),
  1071. required: true,
  1072. }, { //商品名称
  1073. code: 'skuName',
  1074. type: 'textarea',
  1075. title: mixins.$t("skuName"),
  1076. }, {
  1077. code: 'skuImages',
  1078. name: mixins.$t("commodityPicture"), //商品图片
  1079. type: 'uploader',
  1080. },
  1081. ]
  1082. if (data.flgSubUnit) {
  1083. if (data.inventoryCount !== 0) {
  1084. contentObj.unit = [{
  1085. text: '本商品有库存,不可更改单位模块;需全部出库后才可更改',
  1086. type: 'text',
  1087. }, { //基本单位
  1088. code: 'unitId',
  1089. name: 'unitName',
  1090. title: mixins.$t("unit"),
  1091. type: 'choose',
  1092. urlKey: 'unit',
  1093. required: true,
  1094. readonly: data.inventoryCount !== 0 //要校验库存; 库存量不为0不让更改
  1095. }, { //辅助单位标识
  1096. type: 'switch',
  1097. title: mixins.$t("subUnitId"),
  1098. code: 'flgSubUnit',
  1099. disabled: (data.inventoryCount !== 0),
  1100. }, { //包装单位
  1101. code: 'subUnitId',
  1102. name: 'subUnitName',
  1103. title: mixins.$t("packageUnit"),
  1104. type: 'choose',
  1105. urlKey: 'unit',
  1106. required: true,
  1107. readonly: data.inventoryCount !== 0 //要校验库存; 库存量不为0不让更改
  1108. }, { //包装
  1109. code: 'packBox',
  1110. title: mixins.$t("package"),
  1111. type: 'number',
  1112. sign: "",
  1113. digits: 0,
  1114. required: true,
  1115. readonly: data.inventoryCount !== 0
  1116. },
  1117. {
  1118. code: 'calculationFormula',
  1119. type: 'textarea',
  1120. title: mixins.$t("calculationFormula"),
  1121. readonly: true,
  1122. }
  1123. ]
  1124. } else { //没库存
  1125. contentObj.unit = [{ //基本单位
  1126. code: 'unitId',
  1127. name: 'unitName',
  1128. title: mixins.$t("unit"),
  1129. type: 'choose',
  1130. urlKey: 'unit',
  1131. required: true,
  1132. readonly: data.inventoryCount !== 0 //要校验库存; 库存量不为0不让更改
  1133. }, { //辅助单位标识
  1134. type: 'switch',
  1135. title: mixins.$t("subUnitId"),
  1136. code: 'flgSubUnit',
  1137. disabled: (data.inventoryCount !== 0),
  1138. }, { //包装单位
  1139. code: 'subUnitId',
  1140. name: 'subUnitName',
  1141. title: mixins.$t("packageUnit"),
  1142. type: 'choose',
  1143. urlKey: 'unit',
  1144. required: true,
  1145. readonly: data.inventoryCount !== 0 //要校验库存; 库存量不为0不让更改
  1146. }, { //包装
  1147. code: 'packBox',
  1148. title: mixins.$t("package"),
  1149. type: 'number',
  1150. sign: "",
  1151. digits: 0,
  1152. required: true,
  1153. readonly: data.inventoryCount !== 0
  1154. },
  1155. {
  1156. code: 'calculationFormula',
  1157. type: 'textarea',
  1158. title: mixins.$t("calculationFormula"),
  1159. readonly: true,
  1160. }
  1161. ]
  1162. }
  1163. } else {
  1164. contentObj.unit = [{ //基本单位
  1165. code: 'unitId',
  1166. name: 'unitName',
  1167. title: mixins.$t("unit"),
  1168. type: 'choose',
  1169. urlKey: 'unit',
  1170. required: true,
  1171. }, { //辅助单位标识
  1172. type: 'switch',
  1173. title: mixins.$t("subUnitId"),
  1174. code: 'flgSubUnit',
  1175. }, ]
  1176. }
  1177. if (data.flgOpeningInv) {
  1178. if (data.flgSubUnit) { //开了辅助单位
  1179. data.packageBox = data['box'] + data.subUnitName + data['piece'] + data.unitName
  1180. contentObj.warehouse = [{ //期初库存标识
  1181. type: 'switch',
  1182. title: mixins.$t("openingInv"),
  1183. code: 'flgOpeningInv',
  1184. disabled: true,
  1185. }, { //仓库名称
  1186. code: 'whId',
  1187. name: 'whName',
  1188. title: mixins.$t("whName"),
  1189. type: 'choose',
  1190. urlKey: 'openingInventory',
  1191. required: true,
  1192. readonly: true,
  1193. clear: false
  1194. },
  1195. { //库存批号
  1196. code: 'nonStdCode',
  1197. type: 'textarea',
  1198. title: mixins.$t("iinventoryBatchNumber"),
  1199. required: true,
  1200. readonly: true,
  1201. tip: mixins.$t('tipPop'),
  1202. },
  1203. { //期初数量
  1204. code: 'intoQty',
  1205. type: 'number',
  1206. sign: "",
  1207. digits: 0,
  1208. title: mixins.$t("openingInventoryQty"),
  1209. required: true,
  1210. readonly: true,
  1211. },
  1212. {
  1213. code: 'packageBox',
  1214. type: 'str',
  1215. title: mixins.$t("packageBox"),
  1216. required: true,
  1217. readonly: true,
  1218. },
  1219. { //期初成本价
  1220. code: 'priceInto',
  1221. type: 'number',
  1222. title: mixins.$t("iinitialCostPrice"),
  1223. required: true,
  1224. readonly: true,
  1225. },
  1226. ]
  1227. } else {
  1228. contentObj.warehouse = [{ //期初库存标识
  1229. type: 'switch',
  1230. title: mixins.$t("openingInv"),
  1231. code: 'flgOpeningInv',
  1232. disabled: true,
  1233. }, { //仓库名称
  1234. code: 'whId',
  1235. name: 'whName',
  1236. title: mixins.$t("whName"),
  1237. type: 'choose',
  1238. urlKey: 'openingInventory',
  1239. required: true,
  1240. readonly: true,
  1241. clear: false
  1242. },
  1243. { //库存批号
  1244. code: 'nonStdCode',
  1245. type: 'textarea',
  1246. title: mixins.$t("iinventoryBatchNumber"),
  1247. required: true,
  1248. readonly: true,
  1249. tip: mixins.$t('tipPop'),
  1250. },
  1251. { //期初数量
  1252. code: 'intoQty',
  1253. type: 'number',
  1254. sign: "",
  1255. digits: 0,
  1256. title: mixins.$t("openingInventoryQty"),
  1257. required: true,
  1258. readonly: true,
  1259. },
  1260. { //期初成本价
  1261. code: 'priceInto',
  1262. type: 'number',
  1263. title: mixins.$t("iinitialCostPrice"),
  1264. required: true,
  1265. readonly: true,
  1266. },
  1267. ]
  1268. }
  1269. } else {
  1270. contentObj.warehouse = [{ //期初库存标识
  1271. type: 'switch',
  1272. title: mixins.$t("openingInv"),
  1273. code: 'flgOpeningInv',
  1274. disabled: true,
  1275. }, ]
  1276. }
  1277. if (data.flgPrice) {
  1278. contentObj.price = [{ //期初库存标识
  1279. type: 'switch',
  1280. title: mixins.$t("flgPrice"),
  1281. code: 'flgPrice',
  1282. }, { //采购价
  1283. tip: mixins.$t("purchasePricetip"),
  1284. code: 'pricePurchase',
  1285. type: 'number',
  1286. title: mixins.$t("purchasePrice"),
  1287. required: true,
  1288. }, { //零售价
  1289. tip: mixins.$t("retailPricetip"),
  1290. code: 'priceStandard',
  1291. type: 'number',
  1292. title: mixins.$t("retailPrice"),
  1293. required: true,
  1294. }, { //批发价
  1295. tip: mixins.$t("wholesalePricetip"),
  1296. code: 'priceWholesale',
  1297. type: 'number',
  1298. title: mixins.$t("wholesalePrice"),
  1299. required: true,
  1300. }, { //销售限价
  1301. tip: mixins.$t("SaleSPriceLimittip"),
  1302. code: 'priceLimited',
  1303. type: 'number',
  1304. title: mixins.$t("SaleSPriceLimit"),
  1305. required: true,
  1306. }, { //其他价
  1307. tip: mixins.$t("otherPriceLimittip"),
  1308. code: 'priceOther',
  1309. type: 'number',
  1310. title: mixins.$t("otherPriceLimit"),
  1311. required: true,
  1312. }, ]
  1313. } else {
  1314. contentObj.price = [{ //期初库存标识
  1315. type: 'switch',
  1316. title: mixins.$t("flgPrice"),
  1317. code: 'flgPrice',
  1318. }, ]
  1319. }
  1320. if (data.packBox && data.unitName && data.subUnitName) { //选了辅助计量单位 正好 包装也有值 那么直接给出公式
  1321. data.calculationFormula = data.packBox + data.unitName + '= 1' + data.subUnitName
  1322. }
  1323. this.setData({
  1324. contentObj: contentObj,
  1325. formData: JSON.stringify(data),
  1326. buttonList: [{
  1327. name: 'merge',
  1328. title: mixins.$t("save"), //'保存'
  1329. }],
  1330. })
  1331. },
  1332. })