add.js 44 KB

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