guhongwei hace 3 años
padre
commit
665a204eb5

+ 10 - 0
src/router/index.js

@@ -41,6 +41,16 @@ const web = [
         meta: { title: '申报审核' },
         component: () => import('../views/adminCenter/declare/index.vue'),
       },
+      {
+        path: '/adminCenter/purchase/index',
+        meta: { title: '采购管理' },
+        component: () => import('../views/adminCenter/purchase/index.vue'),
+      },
+      {
+        path: '/adminCenter/purchase/detail',
+        meta: { title: '采购管理-采购单' },
+        component: () => import('../views/adminCenter/purchase/detail.vue'),
+      },
       {
         path: '/adminCenter/type/index',
         meta: { title: '商品类型管理' },

+ 4 - 1
src/store/index.js

@@ -9,11 +9,14 @@ import user from '@common/src/store/user';
 import type from '@common/src/store/type';
 // 商品申报
 import apply from '@common/src/store/apply';
+// 采购单
+import buy from '@common/src/store/buy';
+
 Vue.use(Vuex);
 
 export default new Vuex.Store({
   state: { ...ustate },
   mutations: { ...umutations },
   actions: {},
-  modules: { login, user, type, apply },
+  modules: { login, user, type, apply, buy },
 });

+ 8 - 2
src/views/adminCenter/declare/index.vue

@@ -1,6 +1,7 @@
 <template>
   <div id="index">
-    <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @check="toCheck" @del="toDel" @market="toMarket"> </data-table>
+    <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @check="toCheck" @del="toDel" @market="toMarket" @buy="toBuy">
+    </data-table>
     <el-dialog :title="dialog.title" :visible.sync="dialog.show" :width="dialog.width" :before-close="toClose" :close-on-click-modal="false">
       <check-1 v-if="dialog.type == '1'" :form="form" @resetForm="toClose" @onSubmit="onSubmit"></check-1>
       <market-1 v-if="dialog.type == '2'" :form="form"></market-1>
@@ -38,8 +39,9 @@ export default {
         },
       ],
       opera: [
-        { label: '申报商品', method: 'market' },
+        { label: '商品', method: 'market' },
         { label: '审核', method: 'check' },
+        { label: '采购', method: 'buy', display: (i) => i.status == '1' },
         { label: '删除', method: 'del', type: 'danger' },
       ],
       // 弹框
@@ -81,6 +83,10 @@ export default {
       this.$set(this, `form`, data);
       this.dialog = { title: '申报商品', show: true, type: '2', width: '30%' };
     },
+    // 采购
+    toBuy({ data }) {
+      this.$router.push({ path: '/adminCenter/purchase/detail', query: { apply_id: data.id } });
+    },
     // 删除
     async toDel({ data }) {
       let res = await this.delete(data.id);

+ 222 - 0
src/views/adminCenter/purchase/detail.vue

@@ -0,0 +1,222 @@
+<template>
+  <div id="detail">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="one">
+          <el-button type="primary" size="small" @click="back">返回</el-button>
+        </el-col>
+        <el-col :span="24" class="two">
+          <el-form :model="form" :rules="rules" ref="form" label-width="100px">
+            <el-col :span="12">
+              <el-form-item label="采购人" prop="buy_personal">
+                <el-input v-model="form.buy_personal" placeholder="请输入采购人"></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="采购电话" prop="buy_phone">
+                <el-input v-model="form.buy_phone" placeholder="请输入采购电话"></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="收货人" prop="receive_personal">
+                <el-input v-model="form.receive_personal" placeholder="请输入收货人"></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="收货电话" prop="receive_phone">
+                <el-input v-model="form.receive_phone" placeholder="请输入收货电话"></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="收货类型" prop="type">
+                <el-select v-model="form.type" placeholder="请选择收货类型" style="width: 100%">
+                  <el-option label="统一收" value="0"></el-option>
+                  <el-option label="申请人" value="1"></el-option>
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="收货地址" prop="receive_address">
+                <el-input v-model="form.receive_address" placeholder="请输入收货地址"></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="24" class="order">
+              <el-col :span="24" class="btn"><el-button type="primary" size="small" @click="toAddmarket()">添加商品</el-button></el-col>
+              <el-col :span="24" class="list">
+                <el-table :data="form.order" border style="width: 100%">
+                  <el-table-column prop="name" label="商品名称" align="center" show-overflow-tooltip> </el-table-column>
+                  <el-table-column prop="num" label="商品数量" align="center" show-overflow-tooltip> </el-table-column>
+                  <el-table-column prop="desc" label="特殊说明" align="center" show-overflow-tooltip> </el-table-column>
+                  <el-table-column fixed="right" label="操作" align="center">
+                    <template slot-scope="scope"><el-button @click="orderDel(scope.$index, scope.row)" type="danger" size="small">删除</el-button></template>
+                  </el-table-column>
+                </el-table>
+              </el-col>
+            </el-col>
+            <el-col :span="24" style="text-align: center">
+              <el-button type="danger" size="small" @click="resetForm('form')">重置信息</el-button>
+              <el-button type="primary" size="small" @click="onSubmit('form')">提交采购</el-button>
+            </el-col>
+          </el-form>
+        </el-col>
+      </el-col>
+    </el-row>
+    <el-dialog :title="dialog.title" :visible.sync="dialog.show" :width="dialog.width" :before-close="toClose" :close-on-click-modal="false">
+      <el-form :model="orderForm" :rules="orderRules" ref="orderForm" label-width="100px">
+        <el-form-item label="商品名称" prop="name">
+          <el-input v-model="orderForm.name" placeholder="请输入商品名称"></el-input>
+        </el-form-item>
+        <el-form-item label="商品数量" prop="num">
+          <el-input v-model="orderForm.num" placeholder="请输入商品数量"></el-input>
+        </el-form-item>
+        <el-form-item label="特殊说明" prop="desc">
+          <el-input v-model="orderForm.desc" placeholder="请输入特殊说明"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" size="small" @click="onOrderSubmit('orderForm')">保存信息</el-button>
+        </el-form-item>
+      </el-form>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: mapBuy } = createNamespacedHelpers('buy');
+export default {
+  name: 'detail',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      form: { order: [] },
+      rules: {
+        buy_personal: [{ required: true, message: '请输入采购人', trigger: 'blur' }],
+        buy_phone: [{ required: true, message: '请输入采购电话', trigger: 'blur' }],
+        type: [{ required: true, message: '请选择收货类型', trigger: 'blur' }],
+        receive_personal: [{ required: true, message: '请输入收货人', trigger: 'blur' }],
+        receive_phone: [{ required: true, message: '请输入收货电话', trigger: 'blur' }],
+        receive_address: [{ required: true, message: '请输入收货地址', trigger: 'blur' }],
+      },
+      data: [],
+      // 弹框
+      dialog: { title: '申报审核', show: false, type: '1', width: '50%' },
+      // 审核
+      orderForm: {},
+      orderRules: {
+        name: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
+        num: [{ required: true, message: '请输入商品数量', trigger: 'blur' }],
+        desc: [{ required: true, message: '请输入特殊说明', trigger: 'blur' }],
+      },
+    };
+  },
+  async created() {
+    await this.searchOther();
+  },
+  methods: {
+    ...mapBuy(['fetch', 'create', 'update']),
+    // 提交采购
+    onSubmit(formName) {
+      this.$refs[formName].validate(async (valid) => {
+        if (valid) {
+          let data = this.form;
+          let res = await this.create(data);
+          if (this.$checkRes(res)) {
+            this.$message({ type: `success`, message: `操作完成` });
+            this.back();
+          } else {
+            this.$message({ type: `error`, message: `${res.errmsg}` });
+          }
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+    },
+    // 取消采购
+    resetForm(formName) {
+      this.$refs[formName].resetFields();
+      this.searchOther();
+    },
+    // 商品添加
+    toAddmarket() {
+      this.dialog = { title: '采购商品', show: true, type: '1', width: '30%' };
+    },
+    // 提交保存
+    onOrderSubmit(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          let data = this.orderForm;
+          this.form.order.push(data);
+          this.orderForm = {};
+          this.dialog = { title: '采购商品', show: false, type: '1', width: '30%' };
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+    },
+    // 取消添加
+    toClose() {
+      this.dialog = { title: '采购商品', show: false, type: '1', width: '30%' };
+    },
+    // 删除商品
+    orderDel(dataindex) {
+      this.form.order.splice(dataindex, 1);
+    },
+    // 查询其他信息
+    searchOther() {
+      let data = {
+        apply_id: this.apply_id ? this.apply_id : '',
+        buy_personal_id: this.user.id,
+        buy_personal: this.user.name,
+        buy_phone: this.user.phone,
+        status: '0',
+        order: [],
+      };
+      this.$set(this, `form`, data);
+    },
+    // 返回
+    back() {
+      this.$router.push({ path: '/adminCenter/purchase/index' });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    apply_id() {
+      return this.$route.query.apply_id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  .one {
+    text-align: right;
+    margin: 0 0 10px 0;
+  }
+  .two {
+    .order {
+      margin: 0 0 10px 0;
+      .btn {
+        text-align: right;
+        margin: 0 0 10px 0;
+      }
+    }
+  }
+}
+/deep/.el-dialog__body {
+  padding: 10px;
+}
+</style>

+ 120 - 0
src/views/adminCenter/purchase/index.vue

@@ -0,0 +1,120 @@
+<template>
+  <div id="index">
+    <data-table :fields="fields" :opera="opera" @query="search" :data="list" :total="total" @view="toView" @sign="toSign">
+      <template slot="selfbtn">
+        <el-button type="primary" size="small" @click="toAdd()">添加</el-button>
+      </template>
+    </data-table>
+    <el-dialog :title="dialog.title" :visible.sync="dialog.show" :width="dialog.width" :before-close="toClose" :close-on-click-modal="false">
+      <info-1 v-if="dialog.type == '1'" :info="info"></info-1>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import info1 from './parts/info-1.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: mapBuy } = createNamespacedHelpers('buy');
+export default {
+  name: 'index',
+  props: {},
+  components: {
+    info1,
+  },
+  data: function () {
+    return {
+      list: [],
+      total: 0,
+      fields: [
+        { label: '采购人', prop: 'buy_personal', filter: 'input' },
+        { label: '采购电话', prop: 'buy_phone', filter: 'input' },
+        {
+          label: '收货类型',
+          prop: 'type',
+          format: (i) => {
+            return i === '0' ? '统一收' : '申请人';
+          },
+        },
+        { label: '收货人', prop: 'receive_personal' },
+        { label: '收货电话', prop: 'receive_phone' },
+        { label: '收货地址', prop: 'receive_address' },
+        {
+          label: '审核状态',
+          prop: 'status',
+          format: (i) => {
+            return i === '0' ? '待收货' : '';
+          },
+        },
+      ],
+      opera: [
+        { label: '查看信息', method: 'view' },
+        { label: '收货', method: 'sign' },
+      ],
+      // 弹框
+      dialog: { title: '详细信息', show: false, type: '1', width: '50%' },
+      // 详细信息
+      info: {},
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...mapBuy(['query', 'fetch', 'create', 'update']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      let res = await this.query({ skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    toAdd() {
+      this.$router.push({ path: '/adminCenter/purchase/detail' });
+    },
+    // 查看信息
+    toView({ data }) {
+      data.type = data.type == '0' ? '统一收' : '申请人';
+      this.$set(this, `info`, data);
+      this.dialog = { title: '详细信息', show: true, type: '1', width: '50%' };
+    },
+    // 关闭
+    toClose() {
+      this.dialog = { title: '详细信息', show: false, type: '1', width: '50%' };
+    },
+    // 收货
+    async toSign({ data }) {
+      this.$confirm(`您确认提交签收吗?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      })
+        .then(async () => {
+          data.status = '1';
+          let res = await this.updae(data);
+          if (this.$checkRes(res)) {
+            this.$message({ type: `success`, message: `操作成功` });
+            this.search();
+          } else {
+            this.$message({ type: `error`, message: `${res.errmsg}` });
+          }
+        })
+        .catch(() => {});
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 80 - 0
src/views/adminCenter/purchase/parts/info-1.vue

@@ -0,0 +1,80 @@
+<template>
+  <div id="info-1">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="one">
+          <el-form :model="info" ref="info" label-width="100px">
+            <el-col :span="12">
+              <el-form-item label="采购人" prop="buy_personal">
+                <el-input v-model="info.buy_personal" readonly></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="采购电话" prop="buy_phone">
+                <el-input v-model="info.buy_phone" readonly></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="收货人" prop="receive_personal">
+                <el-input v-model="info.receive_personal" readonly></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="收货电话" prop="receive_phone">
+                <el-input v-model="info.receive_phone" readonly></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="收货类型" prop="type">
+                <el-input v-model="info.type" readonly></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="12">
+              <el-form-item label="收货地址" prop="receive_address">
+                <el-input v-model="info.receive_address" readonly></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="24">
+              <el-table :data="info.order" border style="width: 100%">
+                <el-table-column prop="name" label="商品名称" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="num" label="商品数量" align="center" show-overflow-tooltip> </el-table-column>
+                <el-table-column prop="desc" label="特殊说明" align="center" show-overflow-tooltip> </el-table-column>
+              </el-table>
+            </el-col>
+          </el-form>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'info-1',
+  props: {
+    info: { type: Object },
+  },
+  components: {},
+  data: function () {
+    return {};
+  },
+  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>