index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <div class="detil">
  3. <by-tool :propConfig="toolConfig" />
  4. <div class="box-shadow">
  5. <by-form :propConfig="config" ref="form">
  6. <template v-slot:description>
  7. <el-input type="textarea" :rows="5" placeholder="请输入内容" v-model="textarea">
  8. </el-input>
  9. </template>
  10. <template v-slot:radio>
  11. <el-radio v-model="radio" :label="1">单规格</el-radio>
  12. <el-radio v-model="radio" :label="2">多规格</el-radio>
  13. </template>
  14. <template v-slot:status>
  15. <el-radio v-model="radioStatus" :label="1">启用</el-radio>
  16. <el-radio v-model="radioStatus" :label="2">备用</el-radio>
  17. <el-radio v-model="radioStatus" :label="3">禁用</el-radio>
  18. </template>
  19. <template v-slot:ismakeup>
  20. <el-radio v-model="ismakeup" :label="1">是</el-radio>
  21. <el-radio v-model="ismakeup" :label="2">否</el-radio>
  22. </template>
  23. <template v-slot:issued>
  24. <el-radio v-model="issued" :label="1">是</el-radio>
  25. <el-radio v-model="issued" :label="2">否</el-radio>
  26. </template>
  27. </by-form>
  28. </div>
  29. </div>
  30. </template>
  31. <script lang="ts">
  32. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  33. import api from '@/api/material'
  34. @Component
  35. export default class DemoForm extends Vue {
  36. baseURL : any = process.env.VUE_APP_BASE_API
  37. radio : any = 1
  38. radioStatus : any = 1
  39. ismakeup : any = 1
  40. issued : any = 1
  41. textarea : any = ''
  42. toolConfig = {
  43. customTools: [
  44. {
  45. name: '保存', icon: 'el-icon-plus', audit: [''], event: {
  46. click: () => {
  47. (this as any).getFormData()
  48. }
  49. }
  50. }
  51. ]
  52. }
  53. config = {
  54. attr: {
  55. size: 'small',
  56. rules: {
  57. name: [{
  58. required: true, message: '请输入名称', trigger: 'blur'
  59. }],
  60. shortName: [{
  61. required: true, message: '请输入简称', trigger: 'blur'
  62. }]
  63. }
  64. },
  65. columns: [
  66. [
  67. {
  68. span: 6,
  69. label: '名称',
  70. prop: 'name',
  71. component: 'by-input',
  72. compConfig: {
  73. attr: {
  74. placeholder: '请输入名称',
  75. clearable: true
  76. }
  77. }
  78. },
  79. {
  80. span: 6,
  81. label: '简称',
  82. prop: 'shortName',
  83. component: 'by-input',
  84. compConfig: {
  85. attr: {
  86. placeholder: '请输入简称',
  87. clearable: true
  88. }
  89. }
  90. },
  91. {
  92. span: 6,
  93. label: '财务编号',
  94. prop: 'accountingCode',
  95. component: 'by-input',
  96. compConfig: {
  97. attr: {
  98. placeholder: '请输入财务编号',
  99. clearable: true
  100. }
  101. }
  102. },
  103. {
  104. span: 6,
  105. label: '国际码',
  106. prop: 'nsCode',
  107. component: 'by-input',
  108. compConfig: {
  109. attr: {
  110. placeholder: '请输入国际码',
  111. clearable: true
  112. }
  113. }
  114. },
  115. ],
  116. [
  117. {
  118. span: 6,
  119. label: '基本售价',
  120. prop: 'basePrice',
  121. component: 'by-input',
  122. compConfig: {
  123. attr: {
  124. placeholder: '请输入基本售价',
  125. clearable: true
  126. }
  127. }
  128. }, {
  129. span: 6,
  130. label: '市场价格',
  131. prop: 'markPrice',
  132. component: 'by-input',
  133. compConfig: {
  134. attr: {
  135. placeholder: '请输入市场价格',
  136. clearable: true
  137. }
  138. }
  139. },
  140. {
  141. span: 6,
  142. label: '价格',
  143. prop: 'price',
  144. component: 'by-input',
  145. compConfig: {
  146. attr: {
  147. placeholder: '请输入价格(成交、成本价)',
  148. clearable: true
  149. }
  150. }
  151. },
  152. {
  153. span: 6,
  154. label: '单位',
  155. prop: 'unit',
  156. component: 'by-input',
  157. compConfig: {
  158. attr: {
  159. placeholder: '请输入单位',
  160. clearable: true
  161. }
  162. }
  163. },
  164. ],
  165. [
  166. {
  167. span: 6,
  168. label: '重量',
  169. prop: 'weight',
  170. component: 'by-input',
  171. compConfig: {
  172. attr: {
  173. placeholder: '请输入重量',
  174. clearable: true
  175. }
  176. }
  177. },
  178. {
  179. span: 6,
  180. label: '保质期(天)',
  181. prop: 'shelfLife',
  182. component: 'by-input',
  183. compConfig: {
  184. attr: {
  185. placeholder: '请输入保质期(天)',
  186. clearable: true
  187. }
  188. }
  189. },
  190. {
  191. span: 6,
  192. label: '库存',
  193. prop: 'stock',
  194. component: 'by-input',
  195. compConfig: {
  196. attr: {
  197. placeholder: '请输入库存',
  198. clearable: true
  199. }
  200. }
  201. },
  202. {
  203. span: 6,
  204. label: '安全库存',
  205. prop: 'warningStock',
  206. component: 'by-input',
  207. compConfig: {
  208. attr: {
  209. placeholder: '请输入安全库存',
  210. clearable: true
  211. }
  212. }
  213. }
  214. ],
  215. [
  216. {
  217. span: 6,
  218. label: '货号',
  219. prop: 'itemNumber',
  220. component: 'by-input',
  221. compConfig: {
  222. attr: {
  223. placeholder: '请输入货号',
  224. clearable: true
  225. }
  226. }
  227. },
  228. {
  229. span: 6,
  230. label: '分类',
  231. prop: 'select',
  232. component: 'by-select',
  233. compConfig: {
  234. attr: {
  235. placeholder: '请选择数据',
  236. clearable: true,
  237. },
  238. request: '/maindata/maindataMaterialCategory/treeList'
  239. },
  240. },
  241. {
  242. span: 6,
  243. label: '虚拟分类',
  244. prop: 'select',
  245. component: 'by-select',
  246. compConfig: {
  247. attr: {
  248. placeholder: '请选择数据',
  249. clearable: true,
  250. data: [{
  251. value: '选项1',
  252. label: '黄金糕'
  253. }, {
  254. value: '选项2',
  255. label: '双皮奶'
  256. }, {
  257. value: '选项3',
  258. label: '蚵仔煎'
  259. }, {
  260. value: '选项4',
  261. label: '龙须面'
  262. }, {
  263. value: '选项5',
  264. label: '北京烤鸭'
  265. }]
  266. }
  267. }
  268. },
  269. {
  270. span: 6,
  271. label: '厂家物料',
  272. prop: 'factoryId',
  273. component: 'by-select',
  274. compConfig: {
  275. attr: {
  276. placeholder: '请选择数据',
  277. clearable: true,
  278. data: [{
  279. value: '选项1',
  280. label: '黄金糕'
  281. }, {
  282. value: '选项2',
  283. label: '双皮奶'
  284. }, {
  285. value: '选项3',
  286. label: '蚵仔煎'
  287. }, {
  288. value: '选项4',
  289. label: '龙须面'
  290. }, {
  291. value: '选项5',
  292. label: '北京烤鸭'
  293. }]
  294. }
  295. }
  296. }
  297. ],
  298. [
  299. {
  300. span: 6,
  301. label: '机构商品分类',
  302. prop: 'select',
  303. component: 'by-select',
  304. compConfig: {
  305. attr: {
  306. placeholder: '请选择数据',
  307. clearable: true,
  308. data: [{
  309. value: '选项1',
  310. label: '黄金糕'
  311. }, {
  312. value: '选项2',
  313. label: '双皮奶'
  314. }, {
  315. value: '选项3',
  316. label: '蚵仔煎'
  317. }, {
  318. value: '选项4',
  319. label: '龙须面'
  320. }, {
  321. value: '选项5',
  322. label: '北京烤鸭'
  323. }]
  324. }
  325. }
  326. },
  327. {
  328. span: 6,
  329. label: '物料属性表',
  330. prop: 'select',
  331. component: 'by-select',
  332. compConfig: {
  333. attr: {
  334. placeholder: '请选择数据',
  335. clearable: true,
  336. data: [{
  337. value: '选项1',
  338. label: '黄金糕'
  339. }, {
  340. value: '选项2',
  341. label: '双皮奶'
  342. }, {
  343. value: '选项3',
  344. label: '蚵仔煎'
  345. }, {
  346. value: '选项4',
  347. label: '龙须面'
  348. }, {
  349. value: '选项5',
  350. label: '北京烤鸭'
  351. }]
  352. }
  353. }
  354. }
  355. ],
  356. [
  357. {
  358. span: 30,
  359. label: '描述',
  360. slot: true,
  361. prop: 'description',
  362. }
  363. ],
  364. [
  365. {
  366. span: 20,
  367. label: '商品规格',
  368. slot: true,
  369. prop: 'radio',
  370. }
  371. ],
  372. [
  373. {
  374. span: 20,
  375. label: '物料状态',
  376. slot: true,
  377. prop: 'status',
  378. }
  379. ],
  380. [
  381. {
  382. span: 20,
  383. label: '是否组合商品',
  384. slot: true,
  385. prop: 'ismakeup',
  386. }
  387. ],
  388. [
  389. {
  390. span: 20,
  391. label: '是否公布',
  392. slot: true,
  393. prop: 'issued',
  394. }
  395. ],
  396. ],
  397. }
  398. created() {
  399. // 获取机构商品分类
  400. api.institutionList({}).then((res : any) => {
  401. console.log('机构商品分类 ==> ', res);
  402. })
  403. }
  404. doSave() {
  405. this.getFormData()
  406. }
  407. getFormData() {
  408. (this as any).$refs.form.validate().then(() => {
  409. let data : any = (this as any).$refs.form.getValue();
  410. data.description = this.textarea;
  411. data.status = this.radioStatus;
  412. data.ismakeup = this.ismakeup;
  413. data.issued = this.issued;
  414. api.save(data).then((res : any) => {
  415. if (res.code === 200) {
  416. (this as any).$tab.closeOpenPage('/materialFile/productManagement')
  417. this.$message({ type: 'success', message: res.msg })
  418. }
  419. })
  420. });
  421. }
  422. }
  423. </script>
  424. <style lang="scss" scoped>
  425. .detil {
  426. padding: 20px;
  427. .box-shadow {
  428. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  429. padding: 20px;
  430. border-radius: 4px;
  431. border: 1px solid #e6ebf5;
  432. background-color: #fff;
  433. overflow: hidden;
  434. color: #303133;
  435. -webkit-transition: .3s;
  436. transition: .3s;
  437. margin-top: 20px;
  438. }
  439. }
  440. </style>