YY преди 3 години
родител
ревизия
0b49a58238
променени са 4 файла, в които са добавени 219 реда и са изтрити 24 реда
  1. 80 5
      src/views/menu/stock/index.vue
  2. 78 0
      src/views/menu/stock/parts/detail-1.vue
  3. 50 0
      src/views/menu/stock/parts/info-1.vue
  4. 11 19
      src/views/menu/type/index.vue

+ 80 - 5
src/views/menu/stock/index.vue

@@ -1,8 +1,22 @@
 <template>
   <div id="index">
     <el-row>
-      <el-col :span="24" class="main animate__animated animate__backInRight"> test </el-col>
+      <el-col :span="24" class="main animate__animated animate__backInRight">
+        <el-col class="one">
+          <el-button type="primary" size="mini" @click="toAdd()">添加库存商品</el-button>
+        </el-col>
+        <el-col class="two">
+          <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @view="toView" @edit="toEdit" @reset="toReset" @del="toDel">
+          </data-table>
+        </el-col>
+      </el-col>
     </el-row>
+    <e-dialog :dialog="dialog" @toClose="toClose">
+      <template slot="info">
+        <detail-1 v-if="dialog.type == '1'" :form="form" @onSubmit="onSubmit"></detail-1>
+        <info-1 :form="info" v-else></info-1>
+      </template>
+    </e-dialog>
   </div>
 </template>
 
@@ -11,12 +25,67 @@ import { mapState, createNamespacedHelpers } from 'vuex';
 export default {
   name: 'index',
   props: {},
-  components: {},
+  components: {
+    detail1: () => import('./parts/detail-1.vue'),
+    info1: () => import('./parts/info-1.vue'),
+  },
   data: function () {
-    return {};
+    return {
+      // 数据项
+      fields: [
+        { label: '名称', prop: 'name' },
+        { label: '商品类型', prop: 'type_name' },
+        { label: '库存数量', prop: 'num' },
+        { label: '商品单价', prop: 'money' },
+      ],
+      total: 0,
+      opera: [
+        { label: '详细信息', method: 'view' },
+        { label: '信息变更', method: 'edit' },
+      ],
+      // 列表
+      list: [
+        { id: '1111', name: '手抓饼', type_name: '食品', num: '11111', money: '6', stock_type: '固定资产', brief: '十块钱俩' },
+        { id: '1112', name: '烤冷面', type_name: '食品', num: '11111', money: '5', stock_type: '商品', brief: '十块钱也俩' },
+      ],
+      // 弹框
+      dialog: { title: '信息管理', show: false, type: '1' },
+      // 添加表单
+      form: {},
+      //详情
+      info: {},
+    };
   },
   created() {},
-  methods: {},
+  methods: {
+    search() {},
+    // 添加
+    toAdd() {
+      this.dialog = { title: '信息管理', show: true, type: '1', widths: '40%' };
+    },
+    // 提交保存
+    onSubmit(data) {
+      this.toClose();
+    },
+    // 详细信息
+    toView({ data }) {
+      this.$set(this, `info`, data);
+      this.dialog = { title: '详细信息', show: true, type: '2', widths: '40%' };
+    },
+    // 信息变更
+    toEdit({ data }) {
+      this.$set(this, `form`, data);
+      this.dialog = { title: '信息管理', show: true, type: '1', widths: '40%' };
+    },
+    // 密码重置
+    toReset() {},
+    // 删除信息
+    toDel() {},
+    // 关闭弹框
+    toClose() {
+      this.dialog = { show: false };
+    },
+  },
   computed: {
     ...mapState(['user']),
   },
@@ -33,4 +102,10 @@ export default {
 };
 </script>
 
-<style lang="less" scoped></style>
+<style lang="less" scoped>
+.main {
+  .one {
+    margin: 10px 0;
+  }
+}
+</style>

+ 78 - 0
src/views/menu/stock/parts/detail-1.vue

@@ -0,0 +1,78 @@
+<template>
+  <div id="detail-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <data-form :fields="fields" :data="form" :rules="rules" @save="toSave">
+          <template #custom="{ item }">
+            <template v-if="item.model === 'img_url'">
+              <s-upload :limit="1" :data="form.img_url" type="img_url" listType="picture" url="/files/live/upload" @upload="uplSuc" @delete="uplDel"></s-upload>
+            </template>
+          </template>
+        </data-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'detail-1',
+  props: {
+    form: { type: Object },
+  },
+  components: {},
+  data: function () {
+    return {
+      fields: [
+        { label: '商品类型', model: 'stock_type' },
+        { label: '商品类型', model: 'type_name' },
+        { label: '商品名称', model: 'name' },
+        { label: '商品数量', model: 'num' },
+        { label: '商品单价(元)', model: 'money' },
+        { label: '商品简介', model: 'brief' },
+        { label: '商品图片', model: 'img_url', custom: true },
+      ],
+      rules: {
+        stock_type: [{ required: true, message: '请输入商品类型' }],
+        type_name: [{ required: true, message: '请输入商品类型' }],
+        name: [{ required: true, message: '请输入商品名称' }],
+        num: [{ required: true, message: '请输入商品数量' }],
+        money: [{ required: true, message: '请输入商品单价(元)' }],
+        brief: [{ required: true, message: '请输入商品简介' }],
+        img_url: [{ required: true, message: '请上传商品图片' }],
+      },
+    };
+  },
+  created() {},
+  methods: {
+    toSave({ data }) {
+      this.$emit('onSubmit', data);
+    },
+    // 上传图片
+    uplSuc({ type, data }) {
+      let list = this.form[type];
+      this.$set(this.form, `${type}`, [...list, { name: data.name, url: data.uri }]);
+    },
+    // 删除图片
+    uplDel({ type, data, list }) {
+      this.$set(this.form, `${type}`, list);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 50 - 0
src/views/menu/stock/parts/info-1.vue

@@ -0,0 +1,50 @@
+<template>
+  <div id="info-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <data-form :fields="fields" :data="form" :rules="rules" :needSave="false"> </data-form>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'info-1',
+  props: {
+    form: { type: Object },
+  },
+  components: {},
+  data: function () {
+    return {
+      fields: [
+        { label: '商品类型', model: 'stock_type', readonly: true },
+        { label: '商品类型', model: 'type_name', readonly: true },
+        { label: '商品名称', model: 'name', readonly: true },
+        { label: '商品数量', model: 'num', readonly: true },
+        { label: '商品单价(元)', model: 'money', readonly: true },
+        { label: '商品简介', model: 'brief', readonly: true },
+      ],
+      rules: {},
+    };
+  },
+  created() {},
+  methods: {},
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 11 - 19
src/views/menu/type/index.vue

@@ -3,13 +3,10 @@
     <el-row>
       <el-col :span="24" class="main animate__animated animate__backInRight">
         <el-col class="one">
-          <el-button type="primary" size="mini" @click="toAdd()">添加商品类型</el-button>
-        </el-col>
-        <el-col class="two">
           <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search" @view="toView" @edit="toEdit">
-            <!-- <template #selfbtn>
-          <el-button type="primary" size="mini" @click="toAdd()">添加商品类型</el-button>
-          </template> -->
+            <template #selfbtn>
+              <el-button type="primary" size="mini" @click="toAdd()">添加商品类型</el-button>
+            </template>
           </data-table>
         </el-col>
       </el-col>
@@ -36,13 +33,13 @@ export default {
     return {
       // 数据项
       fields: [
-        { label: '类型类别', prop: 'code' },
-        { label: '类型名称', prop: 'name' },
+        { label: '类型类别', prop: 'code', filter: true },
+        { label: '类型名称', prop: 'name', filter: true },
       ],
       total: 0,
       opera: [
-        { label: '详细信息', method: 'view' },
-        { label: '信息变更', method: 'edit' },
+        { label: '详', method: 'view' },
+        { label: '修改', method: 'edit' },
       ],
       // 列表
       list: [
@@ -60,14 +57,15 @@ export default {
   },
   created() {},
   methods: {
-    search() {},
+    search({ skip = 0, limit = 10, ...info } = {}) {},
     // 添加
     toAdd() {
       this.dialog = { title: '信息管理', show: true, type: '1', widths: '40%' };
     },
     // 提交保存
     onSubmit(data) {
-      this.toClose();
+      console.log(data);
+      // this.toClose();
     },
     // 详细信息
     toView({ data }) {
@@ -100,10 +98,4 @@ export default {
 };
 </script>
 
-<style lang="less" scoped>
-.main {
-  .one {
-    margin: 10px 0;
-  }
-}
-</style>
+<style lang="less" scoped></style>