goods-edit.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811
  1. <template>
  2. <view class="goods-edit-page">
  3. <scroll-view scroll-y class="scroll-content">
  4. <view class="title">基本设置</view>
  5. <view class="cell-group">
  6. <view class="cell dubble">
  7. <view class="row">
  8. <view class="label"><span class="required">*</span>商品图片</view>
  9. <view class="value">
  10. <u-upload :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="1"
  11. :previewFullImage="true" :maxCount="1"></u-upload>
  12. </view>
  13. </view>
  14. </view>
  15. <view class="cell">
  16. <view class="row">
  17. <view class="label"><span class="required">*</span>商品名称</view>
  18. <view class="value">
  19. <u-input border="none" inputAlign="left" fontSize="14" v-model="goodsInfo.goodsName"
  20. placeholder="请输入商品名称"></u-input>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="cell">
  25. <view class="row">
  26. <view class="label w280">最低购买数量</view>
  27. <view class="value">
  28. <u-input border="none" type="number" inputAlign="left" fontSize="14"
  29. v-model="goodsInfo.miniNum"></u-input>
  30. </view>
  31. </view>
  32. <view class="desc">默认 1 为没有限制,如设为 2 ,则用户最少买两份才能下单。</view>
  33. </view>
  34. <view class="cell">
  35. <view class="row">
  36. <view class="label">商品单位</view>
  37. <view class="value">
  38. <u-input border="none" inputAlign="left" fontSize="14" v-model="goodsInfo.utils"
  39. placeholder="请输入商品单位,默认为:份,最多一个字"></u-input>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="cell">
  44. <view class="row">
  45. <view class="label"><span class="required">*</span>商品分类</view>
  46. <view class="value" @click="handCheckGoodsType">
  47. <view class="class-name">{{ goodsInfo.goodsTypeName }}</view>
  48. <u-icon name="arrow-right" size="20" color="#6c6c6c"></u-icon>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="cell dubble h240">
  53. <view class="row">
  54. <view class="label">商品描述</view>
  55. <view class="value">
  56. <u--textarea v-model="goodsInfo.rmk" maxlength="100" placeholder="请输入商品描述"></u--textarea>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="title">商品规格</view>
  62. <view class="list-group">
  63. <view class="item" v-for="(item,index) in modelBeanList" :key="item.id">
  64. <view class="cell">
  65. <view class="label"><span class="required">*</span>规格名称</view>
  66. <view class="value">
  67. <u-input border="none" maxlength="20" inputAlign="left" fontSize="14" v-model="item.modelName"
  68. placeholder="请输入规格名称"></u-input>
  69. </view>
  70. </view>
  71. <view class="cell">
  72. <view class="label"><span class="required">*</span>价格</view>
  73. <view class="value">
  74. <u-input border="none" inputAlign="left" fontSize="14" v-model="item.costPrice"
  75. placeholder="请输入价格"></u-input>
  76. </view>
  77. </view>
  78. <view class="cell">
  79. <view class="label"><span class="required">*</span>餐盒费</view>
  80. <view class="value">
  81. <u-input border="none" inputAlign="left" fontSize="14" v-model="item.packingFee"
  82. placeholder="请输入餐盒费"></u-input>
  83. </view>
  84. </view>
  85. <view class="cell">
  86. <view class="label"><span class="required">*</span>库存</view>
  87. <view class="value">
  88. <u-input border="none" type="number" inputAlign="left" @input="inventoryInput(index,$event)" fontSize="14" v-model="item.inventory"
  89. placeholder="请输入库存"></u-input>
  90. <view class="btn" @click="reset(index)">沽清</view>
  91. <view class="btn" @click="addAll(index)">置满</view>
  92. </view>
  93. </view>
  94. <view class="cell">
  95. <view class="label">最大库存</view>
  96. <view class="value">
  97. 9999
  98. </view>
  99. </view>
  100. <view class="cell no-bor">
  101. <view class="del-btn" v-if="item.modelId == null || item.modelId == ''" @click="deleteModel(item)">删除该规格</view>
  102. </view>
  103. </view>
  104. <view class="add-specificatin" @click="addModel">添加规格</view>
  105. </view>
  106. <view class="title">添加属性</view>
  107. <view class="list-group">
  108. <view class="item" v-for="(item,index) in propertyBeanList" :key="item.id">
  109. <view class="cell">
  110. <view class="label"><span class="required">*</span>属性名称</view>
  111. <view class="value">
  112. <u-input border="none" maxlength="5" inputAlign="left" fontSize="14" v-model="item.propertyName"
  113. placeholder="请输入属性名称"></u-input>
  114. </view>
  115. </view>
  116. <view class="cell dubble" style="height: 280rpx;">
  117. <view class="label"><span class="required">*</span>属性描述</view>
  118. <view class="value" style="border: 2rpx solid #ececec; border-radius: 6rpx;">
  119. <u--textarea height="100" v-model="item.propertyList" maxlength="200" placeholder="多个属性用逗号隔开,例如:微辣,变态辣"></u--textarea>
  120. </view>
  121. </view>
  122. <view class="cell no-bor">
  123. <view class="del-btn" @click="deleteProperty(item)">删除该属性</view>
  124. </view>
  125. </view>
  126. <view class="add-specificatin" @click="addProperty">添加属性</view>
  127. </view>
  128. </scroll-view>
  129. <view class="save">
  130. <view class="btn" @click="save">保存</view>
  131. </view>
  132. <popupPickerView :list="goodsTypeList" ref="popupPickerView" @callback="confirm" />
  133. </view>
  134. </template>
  135. <script>
  136. import { mapState } from 'vuex';
  137. import popupPickerView from '../components/popup-picker-view.vue';
  138. export default {
  139. components: {
  140. popupPickerView
  141. },
  142. data() {
  143. return {
  144. goodsTypeUrl: '/goodsTypeManageApi/getGoodsTypeList',
  145. goodsInfoUrl: '/storeGoodsManageApi/getGoodsInfo',
  146. saveUrl: '/storeGoodsManageApi/update',
  147. checkSpecialUrl: '/storeGoodsManageApi/checkSpecial',
  148. fileList: [],
  149. goodsTypeList: [],
  150. typeList: [],
  151. modelBeanList: [{
  152. id: 1,
  153. modelId: '',
  154. modelName: '',
  155. packingFee: '',
  156. salePrice: '',
  157. costPrice: '',
  158. inventory: ''
  159. }],
  160. propertyBeanList: [],
  161. goodsInfo: {
  162. goodsId: '',
  163. pictureUrl: '',
  164. goodsName: '',
  165. miniNum: 1,
  166. utils: '份',
  167. goodsTypeId: '',
  168. goodsTypeName: '',
  169. rmk: '',
  170. modelBeanList: [],
  171. propertyBeanList: [],
  172. },
  173. specifications: [{
  174. id: 1,
  175. name: '',
  176. price: 1,
  177. package: 0,
  178. inventory: 0,
  179. maxInventory: 9999
  180. }],
  181. params: [{
  182. id: 1,
  183. name: '',
  184. subdivide: ''
  185. }],
  186. file: {},
  187. event: {},
  188. goodsId: '',
  189. isSpecial: false,
  190. handleControl: true
  191. }
  192. },
  193. computed: {
  194. ...mapState(['storeInfo'])
  195. },
  196. methods: {
  197. getGoodsInfo(goodsId) {
  198. uni.showLoading({
  199. title: '加载中'
  200. });
  201. var dateStr = (new Date()).getTime();
  202. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  203. this.requst({
  204. url: this.goodsInfoUrl,
  205. data: {
  206. timestamp: dateStr,
  207. sign: sign,
  208. storeId: this.storeInfo.storeId,
  209. storeUserId: this.storeInfo.storeUserId,
  210. goodsId: goodsId
  211. },
  212. success: res => {
  213. if (res.data.rtnBean.rtnCode == 0) {
  214. this.goodsInfo = res.data.obj;
  215. if (this.goodsInfo.utils === '' || this.goodsInfo.utils === null) {
  216. this.goodsInfo.utils = '份'
  217. }
  218. this.modelBeanList = this.goodsInfo.modelBeanList;
  219. let that = this
  220. if (that.modelBeanList.length > 0) {
  221. for (var i = 0; i < that.modelBeanList.length; i++) {
  222. that.modelBeanList[i].costPrice = that.moneyConverter(that.modelBeanList[i].costPrice)
  223. that.modelBeanList[i].packingFee = that.moneyConverter(that.modelBeanList[i].packingFee)
  224. that.$set(that.modelBeanList[i], 'id', i + 1)
  225. }
  226. }
  227. if (that.goodsInfo.propertyBeanList != null) {
  228. that.propertyBeanList = that.goodsInfo.propertyBeanList;
  229. if (that.propertyBeanList != null && that.propertyBeanList.length > 0) {
  230. for (var i = 0; i < that.propertyBeanList.length; i++) {
  231. that.$set(that.propertyBeanList[i], 'id', i + 1)
  232. }
  233. }
  234. }
  235. let picUrl = this.goodsInfo.pictureUrl;
  236. this.fileList.push({
  237. url: picUrl
  238. })
  239. this.check();
  240. }
  241. uni.hideLoading();
  242. },
  243. fail: (e) => {
  244. console.log("接口调用失败:" + JSON.stringify(e));
  245. uni.hideLoading();
  246. }
  247. })
  248. },
  249. check() {
  250. var dateStr = (new Date()).getTime();
  251. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  252. this.requst({
  253. url: this.checkSpecialUrl,
  254. data: {
  255. timestamp: dateStr,
  256. sign: sign,
  257. storeId: this.storeInfo.storeId,
  258. storeUserId: this.storeInfo.storeUserId,
  259. goodsId: this.goodsId
  260. },
  261. success: res => {
  262. if (res.data.rtnBean.rtnCode == 0) {
  263. this.isSpecial = res.data.obj
  264. }
  265. uni.hideLoading();
  266. },
  267. fail: (e) => {
  268. console.log("接口调用失败:" + JSON.stringify(e));
  269. uni.hideLoading();
  270. }
  271. });
  272. },
  273. addModel() {
  274. if (this.isSpecial) {
  275. this.$api.msg("该商品已参加特价菜活动,只有一个规格");
  276. return false;
  277. }
  278. let model = {
  279. id: this.modelBeanList.length + 1,
  280. modelId: '',
  281. modelName: '',
  282. packingFee: '',
  283. salePrice: '',
  284. costPrice: '',
  285. inventory: ''
  286. }
  287. this.modelBeanList.push(model)
  288. },
  289. deleteModel(item) {
  290. if (this.modelBeanList.length === 1) {
  291. uni.showToast({
  292. title: "商品规格至少有一个",
  293. duration: 3000,
  294. icon: 'none',
  295. });
  296. return false
  297. }
  298. let index = this.modelBeanList.indexOf(item)
  299. if (index !== -1) {
  300. this.modelBeanList.splice(index, 1)
  301. }
  302. },
  303. addProperty() {
  304. // if (this.isSpecial) {
  305. // this.$api.msg("该商品已参加特价菜活动,无法添加属性");
  306. // return false;
  307. // }
  308. if (this.propertyBeanList.length == 4) {
  309. uni.showToast({
  310. title: "商品属性最多有四个",
  311. duration: 3000,
  312. icon: 'none',
  313. });
  314. return false
  315. }
  316. let model = {
  317. id: this.propertyBeanList.length + 1,
  318. propertyId: '',
  319. propertyName: '',
  320. propertyList: '',
  321. goodsId: ''
  322. }
  323. this.propertyBeanList.push(model)
  324. },
  325. deleteProperty(item) {
  326. // if (this.propertyBeanList.length === 1) {
  327. // return false
  328. // }
  329. let index = this.propertyBeanList.indexOf(item)
  330. if (index !== -1) {
  331. this.propertyBeanList.splice(index, 1)
  332. }
  333. },
  334. getGoodsTypeList() {
  335. uni.showLoading({
  336. title: '加载中'
  337. });
  338. var dateStr = (new Date()).getTime();
  339. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  340. this.requst({
  341. url: this.goodsTypeUrl,
  342. data: {
  343. timestamp: dateStr,
  344. sign: sign,
  345. storeId: this.storeInfo.storeId,
  346. storeUserId: this.storeInfo.storeUserId
  347. },
  348. success: res => {
  349. if (res.data.rtnBean.rtnCode == 0) {
  350. let arr = []
  351. arr.push(res.data.list);
  352. this.typeList = res.data.list
  353. this.goodsTypeList = arr;
  354. }
  355. uni.hideLoading();
  356. },
  357. fail: (e) => {
  358. console.log("接口调用失败:" + JSON.stringify(e));
  359. uni.hideLoading();
  360. }
  361. })
  362. },
  363. // 删除图片
  364. deletePic(event) {
  365. this.fileList.splice(event.index, 1)
  366. this.goodsInfo.pictureUrl = ''
  367. },
  368. // 新增图片
  369. async afterRead(event) {
  370. this.event = event
  371. this.file = event.file
  372. let file1 = event.file
  373. let fileListLen = this.fileList.length
  374. // lists.map((item) => {
  375. this.fileList.push({
  376. ...file1,
  377. status: 'success',
  378. // message: '上传中'
  379. })
  380. this.goodsInfo.pictureUrl = this.file.url
  381. },
  382. handCheckGoodsType () {
  383. this.$refs.popupPickerView.show()
  384. },
  385. confirm(e) {
  386. this.goodsInfo.goodsTypeId = e.goodsTypeId;
  387. this.goodsInfo.goodsTypeName = e.goodsTypeName;
  388. },
  389. handChangeClass() {
  390. },
  391. addAll(index) {
  392. this.modelBeanList[index].inventory = 9999;
  393. },
  394. reset(index) {
  395. this.modelBeanList[index].inventory = 0;
  396. },
  397. save() {
  398. uni.showLoading({
  399. title: '保存中'
  400. })
  401. this.goodsInfo.modelBeanList = this.modelBeanList;
  402. this.goodsInfo.propertyBeanList= this.propertyBeanList;
  403. let goodsType = ''
  404. if (this.goodsInfo.goodsTypeId !== null || this.goodsInfo.goodsTypeId !== '') {
  405. for (var i = 0; i < this.typeList.length; i++) {
  406. if(this.typeList[i].goodsTypeId === this.goodsInfo.goodsTypeId) {
  407. goodsType = this.typeList[i]
  408. }
  409. }
  410. console.log(goodsType);
  411. }
  412. if (this.goodsInfo.pictureUrl == null || this.goodsInfo.pictureUrl == undefined || this.goodsInfo.pictureUrl == '') {
  413. this.$api.msg("请上传商品图片");
  414. return;
  415. } else if (this.goodsInfo.goodsName == null || this.goodsInfo.goodsName == '') {
  416. this.$api.msg("请输入商品名称");
  417. return;
  418. } else if (this.goodsInfo.goodsName.length > 30) {
  419. this.$api.msg("商品名称不能超过30个字符");
  420. return;
  421. } else if (this.goodsInfo.utils.length > 10 ) {
  422. this.$api.msg("商品单位最多输入十个字符");
  423. return;
  424. } else if (this.goodsInfo.goodsTypeId == null || this.goodsInfo.goodsTypeId == '') {
  425. this.$api.msg("请选择商品分类");
  426. return;
  427. } else if (this.isSpecial && goodsType !== '' && goodsType.type === 1) {
  428. this.$api.msg("特价菜不能修改为必选商品");
  429. return;
  430. } else if (this.modelBeanList.length == 0 || this.modelBeanList == '') {
  431. this.$api.msg("请添加商品规格");
  432. return;
  433. } else {
  434. let that = this
  435. let aoo = true
  436. if(that.propertyBeanList != null && that.propertyBeanList.length > 0) {
  437. let num = false
  438. if (that.propertyBeanList.length > 0 || that.propertyBeanList[0].propertyName || that.propertyBeanList[0].propertyList) {
  439. num = true
  440. }
  441. for (var i = 0; i < that.propertyBeanList.length; i++) {
  442. if (num){
  443. if (that.propertyBeanList[i].propertyName == null || that.propertyBeanList[i].propertyName == '') {
  444. that.$api.msg("请输入属性名称");
  445. aoo = false;
  446. return;
  447. } else if (that.propertyBeanList[i].propertyList == null || that.propertyBeanList[i].propertyList == '') {
  448. that.$api.msg("请输入属性描述");
  449. aoo = false;
  450. return;
  451. } else if (that.propertyBeanList[i].propertyList.indexOf(',') == -1 && that.propertyBeanList[i].propertyList.indexOf(',') == -1) {
  452. this.$api.msg("属性描述必须大于等于两个");
  453. aoo = false;
  454. return;
  455. }
  456. let str = that.propertyBeanList[i].propertyList.replace(/,/g,',')
  457. let arr = str.split(",").map(el => el.trim()).filter(item => item.trim() != '')
  458. if(arr.length <=1){
  459. this.$api.msg("属性描述必须大于等于两个");
  460. aoo = false;
  461. return;
  462. }
  463. that.propertyBeanList[i].propertyList = arr.join(',')
  464. }
  465. }
  466. }
  467. let boo = true;
  468. let regPrice = (/^[0-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/);
  469. // let regPrice = (/^\d+(?=\.{0,1}\d+$|$)/);
  470. if (that.modelBeanList.length > 0) {
  471. for (var i = 0; i < that.modelBeanList.length; i++) {
  472. if (that.modelBeanList[i].modelName == null || that.modelBeanList[i].modelName == '') {
  473. that.$api.msg("请输入规格名称");
  474. boo = false;
  475. return;
  476. } else if (that.modelBeanList[i].costPrice === null || that.modelBeanList[i].costPrice === '') {
  477. that.$api.msg("请输入价格");
  478. boo = false;
  479. return;
  480. } else if (!regPrice.test(that.modelBeanList[i].costPrice)) {
  481. that.$api.msg("价格只能是整数或小数点后两位");
  482. boo = false;
  483. return;
  484. } else if (that.modelBeanList[i].packingFee === null || that.modelBeanList[i].packingFee ===
  485. undefined || that.modelBeanList[i].packingFee === '') {
  486. that.$api.msg("请输入餐盒费");
  487. boo = false;
  488. return;
  489. } else if (that.modelBeanList[i].inventory === null || that.modelBeanList[i].inventory === '') {
  490. that.$api.msg("请输入库存");
  491. boo = false;
  492. return;
  493. } else if (that.modelBeanList[i].inventory > Number(9999)) {
  494. that.$api.msg("库存不能超过最大库存数");
  495. boo = false;
  496. return;
  497. } else if (that.isSpecial && Number(that.modelBeanList[i].costPrice * 100) < Number(that.modelBeanList[i].salePrice)) {
  498. that.$api.msg("商品价格不能小于售价");
  499. boo = false;
  500. return;
  501. }
  502. }
  503. }
  504. if (aoo && boo) {
  505. var dateStr = (new Date()).getTime();
  506. var sign = that.getSign('' + that.storeInfo.storeUserId + dateStr);
  507. if (that.event.file) {
  508. return new Promise((resolve, reject) => {
  509. let a = uni.uploadFile({
  510. url: that.storeInfo.code + this.saveUrl,
  511. filePath: that.goodsInfo.pictureUrl,
  512. name: 'file',
  513. formData: {
  514. timestamp: dateStr,
  515. sign: sign,
  516. storeId: that.storeInfo.storeId,
  517. storeUserId: that.storeInfo.storeUserId,
  518. goodsId: that.goodsInfo.goodsId,
  519. pictureUrl: that.goodsInfo.pictureUrl,
  520. goodsName: that.goodsInfo.goodsName,
  521. miniNum: that.goodsInfo.miniNum || 1,
  522. utils: that.goodsInfo.utils || '份',
  523. goodsTypeId: that.goodsInfo.goodsTypeId,
  524. rmk: that.goodsInfo.rmk || '',
  525. modelBeanListJson: JSON.stringify(that.goodsInfo.modelBeanList),
  526. propertyBeanListJson: JSON.stringify(that.goodsInfo.propertyBeanList)
  527. },
  528. header: {
  529. 'content-type': 'multipart/form-data'
  530. }, // header 值
  531. success: (res) => {
  532. if(res.data) {
  533. let data = JSON.parse(res.data)
  534. if (data.rtnBean.rtnCode == 0) {
  535. uni.hideLoading();
  536. uni.showToast({
  537. title: "保存成功",
  538. duration: 3000,
  539. icon: 'none',
  540. });
  541. var pages = getCurrentPages();
  542. var prevPage = pages[pages.length - 2]; //上一个页面
  543. prevPage.$vm.loadData()
  544. uni.navigateBack();
  545. // return;
  546. } else {
  547. uni.hideLoading();
  548. if (data.rtnBean.rtnMsg != '') {
  549. that.$api.msg(data.rtnBean.rtnMsg);
  550. }
  551. }
  552. } else {
  553. uni.hideLoading();
  554. that.$api.msg('商品更新失败,请稍后重试');
  555. }
  556. },
  557. fail: (res) => {
  558. uni.hideLoading();
  559. }
  560. });
  561. })
  562. } else {
  563. that.requst({
  564. url: that.saveUrl,
  565. data: {
  566. timestamp: dateStr,
  567. sign: sign,
  568. storeId: that.storeInfo.storeId,
  569. storeUserId: that.storeInfo.storeUserId,
  570. goodsId: that.goodsInfo.goodsId,
  571. pictureUrl: that.goodsInfo.pictureUrl,
  572. goodsName: that.goodsInfo.goodsName,
  573. miniNum: that.goodsInfo.miniNum || 1,
  574. utils: that.goodsInfo.utils || '份',
  575. goodsTypeId: that.goodsInfo.goodsTypeId,
  576. rmk: that.goodsInfo.rmk || '',
  577. modelBeanListJson: JSON.stringify(that.goodsInfo.modelBeanList),
  578. propertyBeanListJson: JSON.stringify(that.goodsInfo.propertyBeanList)
  579. },
  580. success: res => {
  581. if (res.data.rtnBean.rtnCode == 0) {
  582. uni.hideLoading();
  583. uni.showToast({
  584. title: "保存成功",
  585. duration: 3000,
  586. icon: 'none',
  587. });
  588. var pages = getCurrentPages();
  589. var prevPage = pages[pages.length - 2]; //上一个页面
  590. prevPage.$vm.loadData()
  591. uni.navigateBack();
  592. // return;
  593. } else {
  594. uni.hideLoading();
  595. if (res.data.rtnBean.rtnMsg != '') {
  596. that.$api.msg(res.data.rtnBean.rtnMsg);
  597. }
  598. }
  599. },
  600. fail: (e) => {
  601. that.isDisable = false;
  602. console.log("接口调用失败:" + JSON.stringify(e));
  603. uni.hideLoading();
  604. },
  605. });
  606. }
  607. }
  608. }
  609. // uni.navigateBack();
  610. },
  611. inventoryInput(index,e){
  612. // 只能输入数字
  613. const inputType = /[^\d]/g
  614. this.$nextTick(function () {
  615. this.modelBeanList[index].inventory = e.replace(inputType,'');
  616. })
  617. }
  618. },
  619. onLoad(options) {
  620. this.goodsId = options.goodsId
  621. if (options.goodsId != undefined && options.goodsId != null && options.goodsId != '') {
  622. this.getGoodsInfo(options.goodsId);
  623. }
  624. this.getGoodsTypeList();
  625. }
  626. }
  627. </script>
  628. <style lang="scss" scoped>
  629. .required {
  630. color: red;
  631. margin-left: 5px;
  632. }
  633. .goods-edit-page {
  634. background-color: #f5f5f5;
  635. width: 100vw;
  636. height: 100vh;
  637. display: flex;
  638. flex-direction: column;
  639. align-items: center;
  640. justify-content: flex-start;
  641. }
  642. .save {
  643. width: 100vw;
  644. @include flexCenter;
  645. z-index: 99;
  646. margin-top: 40rpx;
  647. .btn {
  648. width: 80vw;
  649. height: 80rpx;
  650. border-radius: 40rpx;
  651. background-color: $theme-color;
  652. color: #fff;
  653. @include flexCenter;
  654. }
  655. }
  656. .scroll-content {
  657. height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
  658. height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
  659. }
  660. .title {
  661. height: 80rpx;
  662. padding: 0 40rpx;
  663. box-sizing: border-box;
  664. @include flexStart;
  665. font-size: 36rpx;
  666. }
  667. .cell-group {
  668. background-color: #fff;
  669. border-top: 2px solid transparent;
  670. .cell {
  671. padding: 0 20rpx;
  672. margin: 20rpx 0;
  673. border-bottom: 2rpx solid #ececec;
  674. font-size: $font-base;
  675. }
  676. .cell.dubble {
  677. height: 200rpx;
  678. }
  679. .cell.h240 {
  680. height: 240rpx;
  681. margin-bottom: 0;
  682. }
  683. .cell.h280 {
  684. height: 280rpx;
  685. margin-bottom: 0;
  686. }
  687. .row {
  688. @include flexStart;
  689. padding: 20rpx 0;
  690. }
  691. .dubble {
  692. .row {
  693. @include flexStart(flex-start);
  694. }
  695. }
  696. .label {
  697. width: 180rpx;
  698. }
  699. .label.w280 {
  700. width: 280rpx;
  701. }
  702. .value {
  703. width: calc(100% - 180rpx);
  704. @include between;
  705. }
  706. .class-name {
  707. width: calc(100% - 100rpx);
  708. }
  709. .desc {
  710. color: $uni-color-button;
  711. margin-bottom: 20rpx;
  712. font-size: $font-sm;
  713. }
  714. }
  715. .list-group {
  716. background-color: #fff;
  717. padding: 20rpx;
  718. box-sizing: border-box;
  719. font-size: $font-base;
  720. .item {
  721. box-shadow: 0 0 10rpx #d1d1d1;
  722. padding: 20rpx 20rpx 1rpx;
  723. box-sizing: border-box;
  724. margin-bottom: 20rpx;
  725. }
  726. .cell {
  727. height: 60rpx;
  728. @include flexStart;
  729. margin-bottom: 20rpx;
  730. border-bottom: 2rpx solid #ececec;
  731. }
  732. .label {
  733. width: 160rpx;
  734. }
  735. .value {
  736. width: calc(100% - 160rpx);
  737. @include flexStart;
  738. .btn {
  739. margin-left: 50rpx;
  740. color: $theme-color;
  741. }
  742. }
  743. .no-bor {
  744. border: none;
  745. }
  746. .del-btn {
  747. width: 100%;
  748. color: $uni-color-button;
  749. text-align: center;
  750. }
  751. .dubble {
  752. @include flexStart(flex-start);
  753. padding-top: 20rpx;
  754. box-sizing: border-box;
  755. }
  756. .h240 {
  757. height: 240rpx;
  758. }
  759. }
  760. .add-specificatin {
  761. width: 100%;
  762. text-align: center;
  763. color: $theme-color;
  764. font-size: $font-lg;
  765. }
  766. </style>