Bladeren bron

Merge branch 'master' of http://git.cc-lotus.info/Free-cysci/cysci-website

lrf402788946 4 jaren geleden
bovenliggende
commit
6ef14ef02a

+ 6 - 0
src/router/index.js

@@ -271,6 +271,12 @@ const web = [
         meta: { title: '服务订单' },
         component: () => import('../views/adminCenter/order/list.vue'),
       },
+      {
+        path: '/adminCenter/order/update',
+        name: 'admin_order_update',
+        meta: { title: '修改服务订单' },
+        component: () => import('../views/adminCenter/order/update.vue'),
+      },
       {
         path: '/adminCenter/ticket',
         name: 'admin_ticket',

+ 125 - 7
src/views/adminCenter/order/list.vue

@@ -3,7 +3,18 @@
     <el-row>
       <el-col :span="24" class="main">
         <el-col :span="24" class="one">
-          <data-table :fields="fields" :opera="opera" :data="list" :total="total" @query="search"> </data-table>
+          <data-table
+            :fields="fields"
+            :opera="opera"
+            :data="list"
+            :total="total"
+            @query="search"
+            @edit="toEdit"
+            @confirm="confirm"
+            @cancel="cancel"
+            @reduct="toReduct"
+          >
+          </data-table>
         </el-col>
       </el-col>
     </el-row>
@@ -11,7 +22,9 @@
 </template>
 
 <script>
+const moment = require('moment');
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: policyOrder } = createNamespacedHelpers('policyOrder');
 const { mapActions: policy } = createNamespacedHelpers('policy');
 export default {
   name: 'list',
@@ -21,21 +34,126 @@ export default {
     return {
       list: [],
       total: 0,
-      opera: [],
-      fields: [{ label: '订单号', prop: 'type' }],
+      opera: [
+        {
+          label: '修改',
+          method: 'edit',
+          display: (item) => {
+            return item.status == '0';
+          },
+        },
+        {
+          label: '确认订单',
+          method: 'confirm',
+          display: (item) => {
+            return item.status == '0';
+          },
+        },
+        {
+          label: '取消订单',
+          method: 'cancel',
+          display: (item) => {
+            return item.status == '0';
+          },
+        },
+        {
+          label: '还原订单',
+          method: 'reduct',
+          display: (item) => {
+            return item.status == '1' || item.status == '2';
+          },
+        },
+      ],
+      fields: [
+        { label: '订单号', prop: 'no' },
+        { label: '订单名称', prop: 'name' },
+        { label: '服务类型', prop: 'policy_user_type' },
+        { label: '所属单位', prop: 'mechanism_person' },
+        { label: '购买单位', prop: 'user_name' },
+        { label: '订单总金额', prop: 'money' },
+        { label: '创新券抵扣金额', prop: 'allowance' },
+        { label: '应收金额', prop: 'total' },
+        { label: '提交时间', prop: 'meta.updateAt', format: (i) => moment(i).format('YYYY-MM-DD HH:mm:ss') },
+        {
+          label: '信息状态',
+          prop: 'status',
+          format: (item) => {
+            return item === '0' ? '待确认' : item === '1' ? '订单已确认' : item === '2' ? '订单已取消' : '未识别';
+          },
+        },
+      ],
     };
   },
   created() {
     this.search();
   },
   methods: {
-    ...policy(['query', 'update']),
+    ...policyOrder(['query', 'update']),
+    ...policy({ policyFetch: 'fetch' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.query({ skip, limit, ...info });
       if (this.$checkRes(res)) {
-        console.log(res);
-        // this.$set(this, `list`, res.data);
-        // this.$set(this, `total`, res.total);
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    // 修改
+    toEdit({ data }) {
+      this.$router.push({ path: '/adminCenter/order/update', query: { id: data._id } });
+    },
+    // 确认订单
+    async confirm({ data }) {
+      data.status = '1';
+      let arr = await this.policyFetch(data.policy_id);
+      if (this.$checkRes(arr)) {
+        let policyData = arr.data;
+        if (policyData.discount_type == '全额折扣券') {
+          data.money = Number(data.money);
+          data.allowance = Number(data.money);
+          data.total = 0;
+        } else if (policyData.discount_type == '折扣券') {
+          data.money = Number(data.money);
+          data.allowance = (Number(data.money) * Number(policyData.scale)) / 100;
+          data.total = Number(data.money) - data.allowance;
+        } else if (policyData.discount_type == '定额券') {
+          data.money = Number(data.money);
+          data.allowance = Number(policyData.allowance);
+          data.total = Number(data.money - policyData.allowance);
+        }
+      }
+      let res = await this.update(data);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '订单确认成功',
+          type: 'success',
+        });
+        this.back();
+      }
+    },
+    // 取消订单
+    async cancel({ data }) {
+      data.status = '2';
+      let res = await this.update(data);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '订单取消成功',
+          type: 'success',
+        });
+        this.search();
+      }
+    },
+    // 还原订单
+    async toReduct({ data }) {
+      data.status = '0';
+      data.allowance = 0;
+      data.total = 0;
+      let res = await this.update(data);
+      if (this.$checkRes(res)) {
+        this.$message({
+          message: '订单还原成功',
+          type: 'success',
+        });
+        this.search();
       }
     },
   },

+ 248 - 0
src/views/adminCenter/order/update.vue

@@ -0,0 +1,248 @@
+<template>
+  <div id="update">
+    <el-row>
+      <el-col :span="24" class="main">
+        <el-col :span="24" class="one">
+          <el-col :span="24" class="top">
+            <el-button type="primary" size="mini" @click="back">返回</el-button>
+          </el-col>
+          <el-col :span="24" class="down">
+            <el-form :model="form" ref="form" label-width="100px">
+              <el-col :span="24" class="text">
+                <el-form-item label="需求描述" prop="req_desc">
+                  <el-input v-model="form.req_desc" type="textarea" maxlength="300" :autosize="{ minRows: 4, maxRows: 6 }" show-word-limit></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="订单号" prop="no">
+                  <el-input v-model="form.no" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="订单名称" prop="name">
+                  <el-input v-model="form.name" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="服务机构" prop="mechanism_person">
+                  <el-input v-model="form.mechanism_person" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="联系人" prop="mechanism_name">
+                  <el-input v-model="form.mechanism_name" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="联系电话" prop="mechanism_mobile">
+                  <el-input v-model="form.mechanism_mobile" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="需方机构名称" prop="user_name">
+                  <el-input v-model="form.user_name" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="联系人" prop="person">
+                  <el-input v-model="form.person" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="联系电话" prop="phone">
+                  <el-input v-model="form.phone" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="电子邮箱" prop="email">
+                  <el-input v-model="form.email" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="订单总金额" prop="money">
+                  <el-input v-model="form.money"></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="创新券抵扣额" prop="allowance">
+                  <el-input v-model="form.allowance" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="12" class="text">
+                <el-form-item label="应收金额" prop="total">
+                  <el-input v-model="form.total" disabled></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="24" class="text">
+                <el-form-item label="备注" prop="remark">
+                  <el-input v-model="form.remark" type="textarea" maxlength="300" :autosize="{ minRows: 4, maxRows: 6 }" show-word-limit></el-input>
+                </el-form-item>
+              </el-col>
+              <el-col :span="24" class="formBtn">
+                <el-button type="danger" size="mini" @click="back">取消保存</el-button>
+                <el-button type="primary" size="mini" @click="oneSubmit('form')">提交保存</el-button>
+                <el-button type="primary" size="mini" @click="twoSubmit('form')">确认订单</el-button>
+              </el-col>
+            </el-form>
+          </el-col>
+        </el-col>
+      </el-col>
+    </el-row>
+  </div>
+</template>
+
+<script>
+const { mapActions: policyOrder } = createNamespacedHelpers('policyOrder');
+const { mapActions: policy } = createNamespacedHelpers('policy');
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'update',
+  props: {},
+  components: {},
+  data: function () {
+    return {
+      form: {},
+    };
+  },
+  created() {
+    if (this.id) this.search();
+  },
+  methods: {
+    ...policyOrder(['fetch', 'update']),
+    ...policy({ policyFetch: 'fetch' }),
+    async search() {
+      let res = await this.fetch(this.id);
+      if (this.$checkRes(res)) {
+        this.$set(this, `form`, res.data);
+      }
+    },
+    // 提交保存
+    oneSubmit(formName) {
+      this.$refs[formName].validate(async (valid) => {
+        if (valid) {
+          let data = this.form;
+          let res = await this.update(data);
+          if (this.$checkRes(res)) {
+            this.$message({
+              message: '订单修改成功',
+              type: 'success',
+            });
+            this.back();
+          }
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+    },
+    // 确认订单
+    twoSubmit(formName) {
+      this.$refs[formName].validate(async (valid) => {
+        if (valid) {
+          let data = this.form;
+          data.status = '1';
+          let arr = await this.policyFetch(data.policy_id);
+          if (this.$checkRes(arr)) {
+            let policyData = arr.data;
+            if (policyData.discount_type == '全额折扣券') {
+              data.money = Number(data.money);
+              data.allowance = Number(data.money);
+              data.total = 0;
+            } else if (policyData.discount_type == '折扣券') {
+              data.money = Number(data.money);
+              data.allowance = (Number(data.money) * Number(policyData.scale)) / 100;
+              data.total = Number(data.money) - data.allowance;
+            } else if (policyData.discount_type == '定额券') {
+              data.money = Number(data.money);
+              data.allowance = Number(policyData.allowance);
+              data.total = Number(data.money - policyData.allowance);
+            }
+          }
+          let res = await this.update(data);
+          if (this.$checkRes(res)) {
+            this.$message({
+              message: '订单确认成功',
+              type: 'success',
+            });
+            this.back();
+          }
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+    },
+    // 确认订单,计算金额
+    // async searchMoney(data) {
+    //   let res = await this.policyFetch(data.policy_id);
+    //   if (this.$checkRes(res)) {
+    //     let policyData = res.data;
+    //     if (policyData.discount_type == '全额折扣券') {
+    //       data.money = Number(data.money);
+    //       data.allowance = Number(data.money);
+    //       data.total = 0;
+    //     } else if (policyData.discount_type == '折扣券') {
+    //       data.money = Number(data.money);
+    //       data.allowance = (Number(data.money) * Number(policyData.scale)) / 100;
+    //       data.total = Number(data.money) - data.allowance;
+    //     } else if (policyData.discount_type == '定额券') {
+    //       data.money = Number(data.money);
+    //       data.allowance = Number(policyData.allowance);
+    //       data.total = Number(data.money - policyData.allowance);
+    //     }
+    //   }
+    //   return data;
+    // },
+    back() {
+      this.$router.push({ path: '/adminCenter/order/list' });
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    id() {
+      return this.$route.query.id;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+  watch: {
+    test: {
+      deep: true,
+      immediate: true,
+      handler(val) {},
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.main {
+  border-radius: 10px;
+  box-shadow: 0 0 5px #cccccc;
+  padding: 20px;
+  .top {
+    text-align: right;
+    margin: 0 0 10px 0;
+  }
+  .down {
+    .text {
+      border-bottom: 1px dashed #ccc;
+      padding: 15px 0;
+    }
+    /deep/.el-form-item {
+      margin: 0;
+    }
+    .el-select {
+      width: 100%;
+    }
+    .formBtn {
+      text-align: center;
+      padding: 10px 0;
+    }
+  }
+}
+.main:hover {
+  box-shadow: 0 0 5px #409eff;
+}
+</style>

+ 8 - 4
src/views/adminCenter/policy/create.vue

@@ -49,25 +49,29 @@
               </el-col>
               <el-col :span="12" class="text">
                 <el-form-item label="抵扣比例" prop="scale">
-                  <el-input v-model="form.scale" style="width: 96%"></el-input>
+                  <!-- <el-input v-model="form.scale" style="width: 96%"></el-input> -->
+                  <el-input type="text" oninput="value=value.replace(/[^\d]/g,'')" v-model="form.scale" clearable style="width: 96%"></el-input>
                   <span style="padding: 0 5px">%</span>
                 </el-form-item>
               </el-col>
               <el-col :span="12" class="text">
                 <el-form-item label="面额" prop="allowance">
-                  <el-input v-model="form.allowance" style="width: 96%"></el-input>
+                  <!-- <el-input v-model.number="form.allowance" type="number" style="width: 96%" :suffix-icon="false"></el-input> -->
+                  <el-input type="text" oninput="value=value.replace(/[^\d]/g,'')" v-model="form.allowance" clearable style="width: 96%"></el-input>
                   <span style="padding: 0 5px">元</span>
                 </el-form-item>
               </el-col>
               <el-col :span="12" class="text">
                 <el-form-item label="券总额度" prop="total_allowance">
-                  <el-input v-model="form.total_allowance" style="width: 96%"></el-input>
+                  <!-- <el-input v-model.number="form.total_allowance" style="width: 96%"></el-input> -->
+                  <el-input type="text" oninput="value=value.replace(/[^\d]/g,'')" v-model="form.total_allowance" clearable style="width: 96%"></el-input>
                   <span style="padding: 0 5px">元</span>
                 </el-form-item>
               </el-col>
               <el-col :span="12" class="text">
                 <el-form-item label="单个企业/团队最大额度" prop="unit_allowance" label-width="200px">
-                  <el-input v-model="form.unit_allowance" style="width: 96%"></el-input>
+                  <!-- <el-input v-model.number="form.unit_allowance" style="width: 96%"></el-input> -->
+                  <el-input type="text" oninput="value=value.replace(/[^\d]/g,'')" v-model="form.unit_allowance" clearable style="width: 96%"></el-input>
                   <span style="padding: 0 5px">元</span>
                 </el-form-item>
               </el-col>