commodity.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  5. <a-row>
  6. <a-col :span="12" type='flex' justify="start">
  7. <a-form-model-item label="app是否上架" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="">
  8. <a-switch :checked="model.appState" @change="switchState" ></a-switch>
  9. </a-form-model-item>
  10. </a-col>
  11. </a-row>
  12. <a-row>
  13. <a-col :span="12" type='flex' justify="start">
  14. <a-form-model-item style="width:100%" label="能否储值卡" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="">
  15. <a-switch :checked="model.canStoreCard" @change="storeChange" ></a-switch>
  16. </a-form-model-item>
  17. </a-col>
  18. </a-row>
  19. <a-row>
  20. <a-col :span="12">
  21. <a-form-model-item label="能否积分支付" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="">
  22. <a-switch :checked="model.canIntegralPay" @change="integralPayChange" ></a-switch>
  23. </a-form-model-item>
  24. </a-col>
  25. </a-row>
  26. <a-row>
  27. <a-col :span="12">
  28. <a-form-model-item label="积分支付价格" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="">
  29. <a-input-number v-model="model.integralPrice" :min="0" />
  30. </a-form-model-item>
  31. </a-col>
  32. </a-row>
  33. <a-row>
  34. <a-col :span="24">
  35. <a-form-model-item label="描述" :labelCol="{span:'2',offset:'0'}" :wrapperCol="wrapperCol" prop="">
  36. <j-editor v-model="model.remark" />
  37. </a-form-model-item>
  38. </a-col>
  39. </a-row>
  40. <a-button @click="submitForm">确认</a-button>
  41. </a-form-model>
  42. </j-form-container>
  43. </a-spin>
  44. </template>
  45. <script>
  46. import { getRoomPlans, getSelectList } from "@/api/api";
  47. import { httpAction, getAction } from "@/api/manage";
  48. import { validateDuplicateValue } from "@/utils/util";
  49. import { getUnit } from '@/api/good'
  50. export default {
  51. name: "BusMarketMemberForm",
  52. inject:['treeData', 'dataSource'],
  53. props: {
  54. disabled: {
  55. type: Boolean,
  56. default: false,
  57. required: false,
  58. },
  59. },
  60. data() {
  61. return {
  62. unitData:[],
  63. options: [{
  64. label: '张三',
  65. value: '1'
  66. }],
  67. model: {
  68. id: "",
  69. hotelId: 0,
  70. goodType: '',
  71. goodUnit: '',
  72. barCode: '',
  73. bid:null,
  74. name:'',
  75. sellingPrice:'',
  76. purchases:null,
  77. salesVolume:null,
  78. inventory:null,
  79. appState:false,
  80. canStoreCard:false,
  81. canIntegralPay:false
  82. },
  83. labelCol: {
  84. xs: {
  85. span: 24
  86. },
  87. sm: {
  88. span: 5
  89. },
  90. },
  91. wrapperCol: {
  92. xs: {
  93. span: 24
  94. },
  95. sm: {
  96. span: 16
  97. },
  98. },
  99. confirmLoading: false,
  100. validatorRules: {
  101. name: [{
  102. required: true,
  103. message: "请输入房型!"
  104. }],
  105. marketPrice: [{
  106. required: true,
  107. message: "请填写门市价!"
  108. }],
  109. canLivePersonNum: [{
  110. required: true,
  111. message: "请填写可住人数!"
  112. }],
  113. breakfastNum: [{
  114. required: true,
  115. message: "请填写早餐数量!"
  116. }],
  117. lunchNum: [{
  118. required: true,
  119. message: "请填写中餐数量!"
  120. }],
  121. dinnerNum: [{
  122. required: true,
  123. message: "请填写晚餐数量!"
  124. }],
  125. },
  126. url: {
  127. // add: "/rooms/cesRoomLayout/save",
  128. add:'/rooms/cesGoods/create',
  129. // edit: "/rooms/cesRoomLayout/modify",
  130. edit:'/rooms/cesGoods/modify',
  131. delete:'/rooms/cesGoods/delete'
  132. // queryById: "/rooms/cesRoomLayout/queryById",
  133. },
  134. iconChooseVisible: false,
  135. roomPlans: [],
  136. members: [],
  137. arr:[]
  138. };
  139. },
  140. computed: {
  141. formDisabled() {
  142. return this.disabled;
  143. },
  144. },
  145. created() {
  146. var _info = JSON.parse(localStorage.getItem("storeInfo"));
  147. if (_info) {
  148. this.model.hotelId = _info.id;
  149. this.initData();
  150. this.getData()
  151. }
  152. console.log(111111111111,this.treeData);
  153. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  154. },
  155. methods: {
  156. onChange(e) {
  157. console.log(e);
  158. this.model.goodType = e[e.length-1]
  159. console.log(this.model.goodType);
  160. },
  161. handleChange(e, options) {
  162. console.log(e);
  163. this.model.goodUnit = e
  164. },
  165. initData() {
  166. getRoomPlans(this.model.hotelId, null).then((res) => {
  167. if (res.success) {
  168. this.roomPlans = res.result;
  169. }
  170. });
  171. },
  172. selectIcons() {
  173. this.iconChooseVisible = true;
  174. },
  175. handleIconCancel() {
  176. this.iconChooseVisible = false;
  177. },
  178. handleIconChoose(value) {
  179. console.log(value);
  180. this.model.icon = value;
  181. this.iconChooseVisible = false;
  182. },
  183. add() {
  184. this.edit(this.modelDefault);
  185. },
  186. //筛选分类数组
  187. filterType(array, id){
  188. let arr = []
  189. array.forEach((item, index)=>{
  190. if (item.id==id) {
  191. this.arr[0] = item.parentId
  192. this.arr[1] = item.id
  193. return
  194. }else if(Array.isArray(item.children) && item.children){
  195. this.filterType(item.children, id)
  196. }
  197. })
  198. },
  199. edit(record) {
  200. console.log(22222222,record);
  201. // this.model = Object.assign({}, record);
  202. this.model = JSON.parse(JSON.stringify(record))
  203. console.log(this.filterType(this.treeData, record.goodType));
  204. console.log(this.model);
  205. this.visible = true;
  206. // getSelectList({
  207. // id: this.model.id
  208. // }).then((res) => {
  209. // if (res.success) {
  210. // this.members = res.result;
  211. // }
  212. // });
  213. },
  214. submitForm() {
  215. const that = this;
  216. // 触发表单验证
  217. debugger
  218. this.$refs.form.validate((valid) => {
  219. if (valid) {
  220. that.confirmLoading = true;
  221. let httpurl = "";
  222. let method = "";
  223. if (!this.model.id) {
  224. httpurl += this.url.add;
  225. method = "post";
  226. } else {
  227. httpurl += this.url.edit;
  228. method = "put";
  229. }
  230. if (this.model.payFlag == 0) {
  231. this.model.payAmount = 0;
  232. }
  233. httpAction(httpurl, this.model, method)
  234. .then((res) => {
  235. if (res.success) {
  236. that.$message.success(res.message);
  237. that.$emit("ok");
  238. } else {
  239. that.$message.warning(res.message);
  240. }
  241. })
  242. .finally(() => {
  243. that.confirmLoading = false;
  244. });
  245. }
  246. });
  247. },
  248. getData(){
  249. getUnit({pageNo:1,pageSize:1000}).then(res=>{
  250. console.log(res);
  251. if (res.code && res.code==200) {
  252. this.unitData = res.result.records
  253. }
  254. })
  255. },
  256. switchState(e){
  257. console.log('这是滑动按钮触发',e);
  258. this.model.appState = e
  259. },
  260. storeChange(e){
  261. console.log(e);
  262. this.model.canStoreCard = e
  263. },
  264. integralPayChange(e){
  265. console.log(e);
  266. this.model.canIntegralPay = e
  267. }
  268. },
  269. };
  270. </script>
  271. <style scoped>
  272. .avatar-uploader>.ant-upload {
  273. width: 104px;
  274. height: 104px;
  275. }
  276. </style>