Browse Source

Merge branch 'edit' into live

戴艳蓉 3 years ago
parent
commit
30e0bf3301

+ 1 - 0
package.json

@@ -48,6 +48,7 @@
     "tui-editor": "1.3.3",
     "uglifyjs-webpack-plugin": "^2.2.0",
     "v-viewer": "^1.6.3",
+    "vue-count-to": "^1.0.13",
     "vue-puzzle-verification": "^1.0.2",
     "vue-quill-editor": "^3.0.6",
     "vue-splitpane": "1.0.4",

+ 18 - 0
src/apis/service/stock/spaceCount/index.js

@@ -0,0 +1,18 @@
+// 物业管理员
+import http from "@/apis/axios";
+const api = "admin/";
+export default {
+  // 添加
+  add: (data, params) => http(api + "add", data, "post", params),
+  // 删除
+  delete: (data, params) => http(api + "delete", data, "post", params),
+  // 分页查询
+  list: (data, params) => http(api + "list", data, "post", params),
+  // 详情
+  detail: (data, params) => http(api + "detail", data, "post", params),
+  // 更新
+  update: (data, params) => http(api + "update", data, "post", params),
+  // 修改状态
+  status: (data, params) => http(api + "accountstatus", data, "post", params),
+};
+   

+ 31 - 16
src/views/stock/dataWeido/index.vue

@@ -4,7 +4,7 @@
       v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
     >
       <ex-table
-        v-loading="loading"
+        v-loading="false"
         :table="table"
         :data="tableData"
         :columns="columns"
@@ -27,7 +27,24 @@
           <div style="width: 100%">
             <el-row style="padding: 0 0 0 80px">
               <el-col :span="24">
-                <el-col :span="4" style="width: 120px">
+                <!-- 请选择仓库 -->
+                <el-col :span="5" style="width: 160px">
+                  <el-cascader
+                    placeholder="请选择仓库"
+                    filterable
+                    clearable
+                    :size="searchSize"
+                    v-model="value"
+                    :options="options"
+                    style="width: 100%"
+                    @change="
+                      pageInfo.curr = 1;
+                      parmValue.page = 1;
+                      searchList();
+                    "
+                  ></el-cascader>
+                </el-col>
+                <!-- <el-col :span="4" style="width: 120px">
                   <el-select
                     :size="searchSize"
                     v-model="parmValue.status"
@@ -100,7 +117,7 @@
                   >
                     刷新
                   </el-button>
-                </el-col>
+                </el-col> -->
               </el-col>
             </el-row>
           </div>
@@ -221,7 +238,7 @@ export default {
     powers() {
       let tran =
         this.$store.getters.btnList.find(
-          (item) => item.menu_route == "dataWeido"
+          (item) => item.menu_route == "stockCount"
         ) || {};
       if (tran && tran.action && tran.action.length > 0) {
         return tran.action;
@@ -272,37 +289,35 @@ export default {
       columns: [
         {
           prop: "nickname",
-          label: "真实姓名",
+          label: "仓库编号",
         },
         {
           prop: "role_name",
-          label: "角色名称",
+          label: "仓库名称",
         },
         {
           prop: "mobile",
-          label: "联系电话",
+          label: "当前库存",
         },
         {
           prop: "email",
-          label: "邮箱",
+          label: "待入库",
         },
         {
           prop: "status",
-          label: "状态",
+          label: "待出库",
           _slot_: "status",
           width: "80px",
         },
         {
           prop: "addtime",
-          label: "创建时间",
-          sortable: true,
+          label: "可用库存",
+          // sortable: true,
         },
         {
-          prop: "",
-          label: "操作",
-          fixed: "right",
-          _noset_: true,
-          _slot_: "operation",
+          prop: "addtime",
+          label: "在途库存",
+          // sortable: true,
         },
       ],
     };

+ 0 - 0
src/views/stock/dataWeido/数据维度


+ 63 - 17
src/views/stock/productWeido/index.vue

@@ -1,5 +1,6 @@
 <template>
   <div class="productWeido pagePadding">
+    <div>商品维度</div>
     <div
       v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
     >
@@ -27,7 +28,21 @@
           <div style="width: 100%">
             <el-row style="padding: 0 0 0 80px">
               <el-col :span="24">
-                <el-col :span="4" style="width: 120px">
+                <el-select
+                  v-model="value"
+                  :size="searchSize"
+                  filterable
+                  placeholder="请选择商品"
+                >
+                  <el-option
+                    v-for="item in options"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value"
+                  >
+                  </el-option>
+                </el-select>
+                <!-- <el-col :span="4" style="width: 120px">
                   <el-select
                     :size="searchSize"
                     v-model="parmValue.status"
@@ -100,12 +115,13 @@
                   >
                     刷新
                   </el-button>
-                </el-col>
+                </el-col> -->
               </el-col>
             </el-row>
           </div>
         </template>
-        <template #status="{ scope }">
+        <!-- <template #status="{ scope }">
+          
           <el-tag
             :size="tablebtnSize"
             :type="scope.row.status == '0' ? 'warning' : ''"
@@ -114,7 +130,7 @@
                 .label || '--'
             "
           ></el-tag>
-        </template>
+        </template> -->
         <template #operation="{ scope }">
           <el-tooltip
             v-if="powers.some((item) => item == '020')"
@@ -221,7 +237,7 @@ export default {
     powers() {
       let tran =
         this.$store.getters.btnList.find(
-          (item) => item.menu_route == "productWeido"
+          (item) => item.menu_route == "stockCount"
         ) || {};
       if (tran && tran.action && tran.action.length > 0) {
         return tran.action;
@@ -232,6 +248,28 @@ export default {
   },
   data() {
     return {
+      options: [
+        {
+          value: "选项1",
+          label: "黄金糕",
+        },
+        {
+          value: "选项2",
+          label: "双皮奶",
+        },
+        {
+          value: "选项3",
+          label: "蚵仔煎",
+        },
+        {
+          value: "选项4",
+          label: "龙须面",
+        },
+        {
+          value: "选项5",
+          label: "北京烤鸭",
+        },
+      ],
       sitem: null,
       // 状态
       statusOptions: [
@@ -272,37 +310,45 @@ export default {
       columns: [
         {
           prop: "nickname",
-          label: "真实姓名",
+          label: "商品编码",
         },
         {
           prop: "role_name",
-          label: "角色名称",
+          label: "商品名称",
         },
         {
           prop: "mobile",
-          label: "联系电话",
+          label: "分类",
         },
         {
           prop: "email",
-          label: "邮箱",
+          label: "单位",
         },
         {
           prop: "status",
-          label: "状态",
+          label: "当前库存",
           _slot_: "status",
           width: "80px",
         },
         {
           prop: "addtime",
-          label: "创建时间",
-          sortable: true,
+          label: "待入库",
+          // sortable: true,
         },
         {
-          prop: "",
-          label: "操作",
-          fixed: "right",
-          _noset_: true,
-          _slot_: "operation",
+          prop: "addtime",
+          label: "待出库",
+          // sortable: true,
+        },
+        {
+          prop: "addtime",
+          label: "可用库存",
+          // sortable: true,
+        },
+        {
+          prop: "addtime",
+          label: "在途库存",
+          // sortable: true,
         },
       ],
     };

+ 362 - 0
src/views/stock/spaceCount/addEdit.vue

@@ -0,0 +1,362 @@
+<template>
+  <el-dialog
+    :title="title"
+    :center="true"
+    align="left"
+    top="5vh"
+    width="1040px"
+    @close="closeModel"
+    :close-on-click-modal="false"
+    :visible.sync="showModelThis"
+    v-loading="loading"
+    element-loading-text="拼命加载中"
+    element-loading-spinner="el-icon-loading"
+    element-loading-background="rgba(0, 0, 0, 0.8)"
+  >
+    <el-card>
+      <el-row :gutter="10">
+        <el-col :span="24">
+          <el-form
+            :model="ruleForm"
+            status-icon
+            :rules="rulesThis"
+            ref="ruleForm"
+            label-width="110px"
+            class="demo-ruleForm"
+          >
+            <el-form-item
+              label="登录名"
+              prop="loginName"
+              v-if="id === 'add' || isDetail"
+            >
+              <el-input
+                v-model="ruleForm.loginName"
+                :disabled="isDetail"
+              ></el-input>
+            </el-form-item>
+            <el-form-item label="姓名" prop="fullName">
+              <el-input
+                v-model="ruleForm.fullName"
+                :disabled="isDetail"
+              ></el-input>
+            </el-form-item>
+            <el-form-item label="手机号" prop="tel">
+              <el-input v-model="ruleForm.tel" :disabled="isDetail"></el-input>
+            </el-form-item>
+            <el-form-item label="密码" prop="password" v-if="id === 'add'">
+              <el-input
+                type="password"
+                placeholder="密码"
+                :maxlength="20"
+                v-model="ruleForm.password"
+              ></el-input>
+            </el-form-item>
+            <el-form-item label="确认密码" prop="password2" v-if="id === 'add'">
+              <el-input
+                type="password"
+                placeholder="再次输入密码"
+                :maxlength="20"
+                v-model="ruleForm.password2"
+              ></el-input>
+            </el-form-item>
+          </el-form>
+        </el-col>
+        <el-col :span="24" style="text-align: right;">
+          <el-button type="primary" @click="submitForm" v-if="!isDetail"
+            >保 存
+          </el-button>
+          <el-button @click="showModelThis = false">{{ isDetail ? "关 闭" : "取 消" }}</el-button>
+        </el-col>
+      </el-row>
+    </el-card>
+  </el-dialog>
+   </template>
+   <script>
+   import asyncRequest from "@/apis/service/stock/spaceCount";
+   import resToken from "@/mixins/resToken";
+   import {
+    isnumber,
+    isMobile,
+    validEmail,
+    isAlphanumeric,
+    isChinese,
+    isEmoticon,
+    validAlphabets,
+  } from "@/utils/validate";
+   export default {
+    name: 'spaceCount',
+    props: ["showModel", "id", "isDetail","sitem"],
+    mixins: [resToken],
+    data() {
+      const validateusername = (rule, value, callback) => {
+        if (value === "") {
+          callback(new Error("账号不能为空!"));
+        } else {
+          if (value.length < 6 || value.length > 18) {
+            callback(new Error("账号规则为6~18位数字与字母组合!"));
+          } else {
+            if (isnumber(value)) {
+              callback(new Error("账号规则为6~18位数字与字母组合!"));
+            } else if (validAlphabets(value)) {
+              callback(new Error("账号规则为6~18位数字与字母组合!"));
+            } else if (!isAlphanumeric(value)) {
+              callback(new Error("账号规则为6~18位数字与字母组合!"));
+            } else {
+              callback();
+            }
+          }
+        }
+      };
+      const validatename = (rule, value, callback) => {
+        if (value === "") {
+          callback(new Error("真实姓名不能为空!"));
+        } else {
+          if (value.length < 2 || value.length > 12) {
+            callback(new Error("真实姓名规则为2~12位汉字!"));
+          } else {
+            if (!isChinese(value)) {
+              console.log(9999);
+              callback(new Error("真实姓名规则为2~12位汉字!"));
+            } else if (isEmoticon(value)) {
+              console.log(2345);
+              callback(new Error("真实姓名规则为2~12位汉字!"));
+            } else {
+              callback();
+            }
+          }
+        }
+      };
+      const validatemobile = (rule, value, callback) => {
+        if (value === "") {
+          callback(new Error("手机号不能为空!"));
+        } else {
+          if (!isMobile(value)) {
+            callback(new Error("手机号格式不正确!"));
+          } else {
+            callback();
+          }
+        }
+      };
+  
+      const validateEmail = (rule, value, callback) => {
+        if (value === "") {
+          callback();
+        } else {
+          if (!validEmail(value)) {
+            callback(new Error("邮箱格式不正确!"));
+          } else {
+            callback();
+          }
+        }
+      };
+      return {
+        loading: false,
+        title: "添加账号",
+        showModelThis: this.showModel,
+        ruleForm: {
+          username: "", // 账号
+          name: "", // 真实姓名
+          mobile: "",
+          email: "",
+          role_id: "",
+          status: "1",
+          item: [],
+        },
+        rulesThis: this.rules,
+        rules: {
+          name: [
+            {
+              required: true,
+              validator: validatename,
+              trigger: "blur",
+            },
+          ],
+          username: [
+            {
+              required: true,
+              validator: validateusername,
+              trigger: "blur",
+            },
+          ],
+          mobile: [
+            {
+              required: true,
+              validator: validatemobile,
+              trigger: "blur",
+            },
+          ],
+          email: [
+            {
+              required: false,
+              validator: validateEmail,
+              trigger: "blur",
+            },
+          ],
+          role_id: [
+            {
+              required: true,
+              message: "请选择角色",
+              trigger: "change",
+            },
+          ],
+          item: [
+            {
+              type: "array",
+              required: true,
+              message: "请选择所在部门",
+              trigger: "change",
+            },
+          ],
+          status: [
+            {
+              required: true,
+              message: "请选择状态",
+              trigger: "change",
+            },
+          ],
+        }
+      };
+    },
+    watch: {
+      showModel: function(val) {
+        this.showModelThis = val;
+        if (val) {
+          this.initForm();
+        }
+      },
+      showModelThis(val) {
+        if (!val) {
+          this.$emit("cancel");
+        }
+      }
+    },
+    methods: {
+      closeModel() {
+        console.log("closeModel!!");
+      },
+      async initForm() {
+        this.loading = true;
+        // await this.getRole();
+        if (this.id === "add") {
+          this.title = "添加账号";
+          this.rulesThis = this.rules;
+          await this.resetForm();
+        } else {
+          if (this.isDetail) {
+            this.title = "账号详情";
+            this.rulesThis = {};
+          } else {
+            this.title = "修改账号";
+            this.rulesThis = this.rules;
+          }
+          await this.resetForm(this.sitem);
+          // await this.initData()
+        }
+        this.loading = false;
+      },
+      // async getRole() {
+      //   const model = {
+      //     status: "", // 状态
+      //     level: "", // 姓名
+      //     role_name: "",
+      //   };
+      //   const res = await asyncRequest.getRole(model);
+      //   if (res && res.code === 0 && res.data) {
+      //     this.roleList = res.data;
+      //     this.roleList.map((v1) => {
+      //       v1.id += "";
+      //       v1.status += "";
+      //       return v1;
+      //     });
+      //   }
+      // },
+      async initData() {
+        const res = await asyncRequest.detail({ id: this.id });
+      if (res && res.code === 0 && res.data) {
+        this.ruleForm = res.data;
+        this.ruleForm.role_id = this.ruleForm.role;
+      } else if (res && res.code >= 100 && res.code <= 104) {
+        await this.logout();
+      } else {
+        this.$message.warning(res.message);
+      }
+      },
+      async resetForm(sitem) {
+        // 重置
+        await this.$nextTick(() => {
+          if (this.$refs.ruleForm) {
+            this.$refs.ruleForm.resetFields();
+            this.$refs.ruleForm.clearValidate();
+            const { username, nickname, mobile, email, roleid, status, item } =
+              sitem;
+            this.ruleForm = {
+              username: username || "", // 账号
+              name: nickname || "", // 真实姓名
+              mobile: mobile || "",
+              email: email || "",
+              role_id: roleid || "",
+              status: status || "",
+              item: item || [],
+            };
+            if (this.id === "add" || this.isDetail) {
+              this.rules.username[0].required = false;
+            }
+          }
+        });
+      },
+    
+      async submitForm() {
+        await this.$refs.ruleForm.validate(async (valid) => {
+          if (valid) {
+            this.loading = true;
+            const { username, name, mobile, email, role_id, status } = JSON.parse(
+              JSON.stringify(this.ruleForm)
+            );
+            const model = {
+              id: this.id,
+              username: username || "", // 账号
+              nickname: name || "", // 真实姓名
+              mobile: mobile || "",
+              email: email || "",
+              role: role_id || "",
+              status: status || "",
+            };
+            let res = {};
+            if (this.id === "add") {
+              delete model["id"];
+              res = await asyncRequest.add(model);
+            } else {
+              res = await asyncRequest.update(model);
+            }
+            this.loading = false;
+            if (res && res.code === 0) {
+              const title = this.id === "add" ? "添加成功" : "修改成功";
+              this.$notify.success({
+                title,
+                message: "",
+              });
+              this.showModelThis = false;
+              // 刷新
+              this.$emit("refresh");
+            } else if (res && res.code >= 100 && res.code <= 104) {
+              await this.logout();
+            } else {
+              this.$message.warning(res.message);
+            }
+          } else {
+            console.log("error submit!!");
+            return false;
+          }
+        });
+      },
+    },
+ 
+  };
+  </script>
+
+   <style lang="scss" scoped>
+   .spaceCount {
+    
+   }
+   </style>
+   

+ 59 - 67
src/views/stock/nowCount/index.vue → src/views/stock/spaceCount/index.vue

@@ -1,5 +1,7 @@
 <template>
-  <div class="nowCount pagePadding">
+  <div class="spaceCount pagePadding">
+    <div>区间统计</div>
+
     <div
       v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
     >
@@ -27,43 +29,54 @@
           <div style="width: 100%">
             <el-row style="padding: 0 0 0 80px">
               <el-col :span="24">
-                <el-col style="width: 255px">
-                  <el-tabs v-model="activeName" @tab-click="handleClick">
-                    <el-tab-pane
-                      label="商品维度"
-                      name="productWeido"
-                    ></el-tab-pane>
-                    <el-tab-pane
-                      label="数据维度"
-                      name="dataWeido"
-                    ></el-tab-pane>
-                    <el-tab-pane label="区间统计" name="count"></el-tab-pane>
-                  </el-tabs>
-                </el-col>
-
-                <!-- <el-col :span="4" style="width: 120px">
-                  <el-select
-                    :size="searchSize"
-                    v-model="parmValue.status"
+                <!-- 请选择仓库 -->
+                <el-col :span="5" style="width: 160px">
+                  <el-cascader
+                    placeholder="请选择仓库"
                     filterable
                     clearable
-                    placeholder="账号状态"
+                    :size="searchSize"
+                    v-model="value"
+                    :options="options"
                     style="width: 100%"
                     @change="
                       pageInfo.curr = 1;
                       parmValue.page = 1;
                       searchList();
                     "
+                  ></el-cascader>
+                </el-col>
+
+                <el-col :span="4" style="width: 120px">
+                  <el-select
+                    v-model="value"
+                    :size="searchSize"
+                    filterable
+                    placeholder="请选择商品"
                   >
                     <el-option
-                      v-for="item in statusList"
-                      :key="'status' + item.code"
-                      :label="item.name"
-                      :value="item.code"
-                    />
+                      v-for="item in options"
+                      :key="item.value"
+                      :label="item.label"
+                      :value="item.value"
+                    >
+                    </el-option>
                   </el-select>
                 </el-col>
-                <el-col :span="4" style="width: 150px; padding: 0 0 0 10px">
+
+                <el-col :span="6" style="width: 352px; padding: 0 0 0 20px">
+                  <number-range
+                    :start="parmValue.total_low"
+                    :end="parmValue.total_up"
+                    :type="1"
+                    :width="'150px'"
+                    :title="'开始时间'"
+                    :size="searchSize"
+                    @numReturned="numReturned($event, 0)"
+                  />
+                </el-col>
+
+                <!-- <el-col :span="4" style="width: 150px; padding: 0 0 0 10px">
                   <el-input
                     :size="searchSize"
                     v-model="parmValue.name"
@@ -219,24 +232,25 @@ import mixinPage from "@/mixins/elPaginationHandle";
 import resToken from "@/mixins/resToken";
 import ExTable from "@/components/ExTableNew.vue";
 import statusList from "@/assets/js/statusList";
-import asyncRequest from "@/apis/service/stock/nowCount";
-import dataWeido from "@/views/stock/dataWeido";
+import asyncRequest from "@/apis/service/stock/spaceCount";
 import addEdit from "./addEdit";
 import { mapGetters } from "vuex";
+import numberRange from "@/components/numberRange";
 
 export default {
-  name: "nowCount",
+  name: "spaceCount",
   mixins: [mixinPage, resToken],
   components: {
     addEdit,
     ExTable,
+    numberRange,
   },
   computed: {
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
     powers() {
       let tran =
         this.$store.getters.btnList.find(
-          (item) => item.menu_route == "nowCount"
+          (item) => item.menu_route == "stockCount"
         ) || {};
       if (tran && tran.action && tran.action.length > 0) {
         return tran.action;
@@ -247,7 +261,6 @@ export default {
   },
   data() {
     return {
-      activeName: "productWeido", //默认选中的区间统计选项
       sitem: null,
       // 状态
       statusOptions: [
@@ -288,40 +301,37 @@ export default {
       columns: [
         {
           prop: "nickname",
-          label: "商品编码",
+          label: "真实姓名",
         },
         {
           prop: "role_name",
-          label: "商品名称",
+          label: "角色名称",
         },
         {
           prop: "mobile",
-          label: "单位",
+          label: "联系电话",
         },
         {
           prop: "email",
-          label: "当前库存",
+          label: "邮箱",
         },
         {
           prop: "status",
-          label: "待入库",
-          // _slot_: "status",
-          // width: "80px",
-        },
-        {
-          prop: "addtime",
-          label: "待出库",
-          // sortable: true,
+          label: "状态",
+          _slot_: "status",
+          width: "80px",
         },
         {
           prop: "addtime",
-          label: "可用库存",
-          // sortable: true,
+          label: "创建时间",
+          sortable: true,
         },
         {
-          prop: "addtime",
-          label: "在途库存",
-          // sortable: true,
+          prop: "",
+          label: "操作",
+          fixed: "right",
+          _noset_: true,
+          _slot_: "operation",
         },
       ],
     };
@@ -331,24 +341,6 @@ export default {
   },
 
   methods: {
-    handleClick(tab, event) {
-      console.log("切换");
-      // console.log(tab.index);tab.index表示点击的唯一编号
-      let id = tab.index;
-      // console.log(event);
-      console.log(id);
-      if (id === "0") {
-        console.log("点击了商品维度");
-      } else if (id === "1") {
-        console.log("点击了数据维度");
-        this.$router.push({
-          path: "/stock/dataWeido",
-          components: dataWeido,
-        });
-      } else {
-        console.log("点击了区间统计");
-      }
-    },
     restSearch() {
       this.parmValue = {
         name: "", // 业务员名字
@@ -444,7 +436,7 @@ export default {
 };
 </script>
    <style lang="scss" scoped>
-.nowCount {
+.spaceCount {
 }
 </style>
    

+ 0 - 0
src/views/stock/spaceCount/区间统计


+ 0 - 0
src/views/stock/nowCount/addEdit.vue → src/views/stock/stockCount/addEdit.vue


+ 288 - 0
src/views/stock/stockCount/index.vue

@@ -0,0 +1,288 @@
+<template>
+  <div class="nowCount pagePadding">
+    <div
+      v-if="powers && powers.length > 0 && powers.some((item) => item == '001')"
+    >
+      <div style="width: 100%">
+        <el-row style="padding: 0 0 0 80px">
+          <el-col :span="24">
+            <el-col style="width: 255px">
+              <el-tabs v-model="activeName" @tab-click="handleClick">
+                <el-tab-pane label="商品维度" name="productWeido"></el-tab-pane>
+                <el-tab-pane label="数据维度" name="dataWeido"></el-tab-pane>
+                <el-tab-pane label="区间统计" name="count"></el-tab-pane>
+              </el-tabs>
+            </el-col>
+          </el-col>
+        </el-row>
+      </div>
+      <ProductWeido v-if="activeName === 'productWeido'"></ProductWeido>
+      <DataWeido v-else-if="activeName === 'dataWeido'"></DataWeido>
+      <SpaceCount v-else></SpaceCount>
+      <add-edit
+        :id="modelId"
+        :sitem="sitem"
+        :show-model="showModel"
+        :is-detail="isDetail"
+        @refresh="searchList"
+        @cancel="showModel = false"
+      />
+    </div>
+    <div v-else>
+      <no-auth></no-auth>
+    </div>
+
+    <add-edit
+      :showModel="showModel"
+      :id="modelId"
+      :isDetail="isDetail"
+      @refresh="searchList"
+      @cancel="showModel = false"
+    ></add-edit>
+  </div>
+</template>
+   <script>
+import mixinPage from "@/mixins/elPaginationHandle";
+import resToken from "@/mixins/resToken";
+import ExTable from "@/components/ExTableNew.vue";
+import statusList from "@/assets/js/statusList";
+import asyncRequest from "@/apis/service/stock/nowCount";
+import DataWeido from "@/views/stock/dataWeido";
+import ProductWeido from "@/views/stock/productWeido";
+import SpaceCount from "@/views/stock/spaceCount";
+
+import addEdit from "./addEdit";
+import { mapGetters } from "vuex";
+
+export default {
+  name: "stockCount",
+  mixins: [mixinPage, resToken],
+  components: {
+    addEdit,
+    ExTable,
+    DataWeido,
+    ProductWeido,
+    SpaceCount,
+  },
+  computed: {
+    ...mapGetters(["tablebtnSize", "searchSize", "size"]),
+    powers() {
+      let tran =
+        this.$store.getters.btnList.find(
+          (item) => item.menu_route == "stockCount"
+        ) || {};
+      if (tran && tran.action && tran.action.length > 0) {
+        return tran.action;
+      } else {
+        return [];
+      }
+    },
+  },
+  data() {
+    return {
+      activeName: "productWeido", //默认选中的区间统计选项
+      sitem: null,
+      // 状态
+      statusOptions: [
+        { id: "0", label: "禁用" },
+        { id: "1", label: "启用" },
+      ],
+      isShowProduct: true,
+      isShowStock: false,
+      isShowSpace: false,
+      statusList: statusList,
+      loading: true,
+      showModel: false,
+      isDetail: false,
+      modelId: 0,
+      parmValue: {
+        name: "", // 业务员名字
+        username: "", // 账号
+        status: "", //
+        page: 1, // 页码
+        size: 15, // 每页显示条数
+      },
+      tableData: [],
+      passwordModel: false,
+      passwordModelId: 0,
+      isPasswordDetail: false,
+      // 表格 - 数据
+      tableData: [],
+      // 表格 - 参数
+      table: {
+        stripe: true,
+        border: true,
+        _defaultHeader_: ["setcol"],
+      },
+      // 表格 - 分页
+      pageInfo: {
+        size: 15,
+        curr: 1,
+        total: 0,
+      },
+      // 表格 - 列参数
+      columns: [
+        {
+          prop: "nickname",
+          label: "商品编码",
+        },
+        {
+          prop: "role_name",
+          label: "商品名称",
+        },
+        {
+          prop: "mobile",
+          label: "单位",
+        },
+        {
+          prop: "email",
+          label: "当前库存",
+        },
+        {
+          prop: "status",
+          label: "待入库",
+          // _slot_: "status",
+          // width: "80px",
+        },
+        {
+          prop: "addtime",
+          label: "待出库",
+          // sortable: true,
+        },
+        {
+          prop: "addtime",
+          label: "可用库存",
+          // sortable: true,
+        },
+        {
+          prop: "addtime",
+          label: "在途库存",
+          // sortable: true,
+        },
+      ],
+    };
+  },
+  mounted() {
+    this.searchList();
+  },
+
+  methods: {
+    handleClick(tab, event) {
+      console.log("切换");
+      // console.log(tab.index);tab.index表示点击的唯一编号
+      let id = tab.index;
+      // console.log(event);
+      console.log(id);
+      if (id === "0") {
+        console.log("点击了商品维度");
+      } else if (id === "1") {
+        console.log("点击了数据维度");
+        this.isShowSpace = false;
+        this.isShowProduct = false;
+        this.isShowStock = true;
+      } else if (id === "2") {
+        console.log("点击了区间统计");
+        this.isShowSpace = true;
+        this.isShowStock = false;
+        this.isShowProduct = false;
+      }
+    },
+    restSearch() {
+      this.parmValue = {
+        name: "", // 业务员名字
+        username: "", // 账号
+        status: "", //
+        page: 1, // 页码
+        size: 10, // 每页显示条数
+      };
+      this.searchList();
+    },
+
+    openModal(id, isDetail, sitem) {
+      this.showModel = true;
+      this.modelId = id;
+      this.isDetail = isDetail;
+      this.sitem = sitem;
+    },
+    async deleteById(id, status) {
+      await this.$confirm("确定要删除?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(async () => {
+          const model = {
+            id: id,
+            status: status === "1" ? "0" : "1",
+          };
+          const res = await asyncRequest.status(model);
+          if (res && res.code === 0) {
+            this.$notify.success({
+              title: "删除成功",
+              message: "",
+            });
+            this.searchList();
+          } else if (res && res.code >= 100 && res.code <= 104) {
+            await this.logout();
+          } else {
+            this.$message.warning(res.message);
+          }
+        })
+        .catch(() => {
+          console.log("取消");
+        });
+    },
+    async searchList() {
+      this.loading = true;
+      const res = await asyncRequest.list(this.parmValue);
+      if (res && res.code === 0 && res.data) {
+        this.tableData = res.data.list;
+        this.pageInfo.total = Number(res.data.count);
+      } else if (res && res.code >= 100 && res.code <= 104) {
+        await this.logout();
+      } else {
+        this.tableData = [];
+        this.pageInfo.total = 0;
+      }
+      this.loading = false;
+    },
+
+    async statusConfirm(id, status) {
+      let str = status === "1" ? "禁用" : "启用";
+      await this.$confirm("确定要改为" + str + "?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(async () => {
+          this.loading = true;
+          const model = {
+            id: id,
+            status: status === "1" ? "0" : "1",
+          };
+          const res = await asyncRequest.status(model);
+          if (res && res.code === 0) {
+            this.loading = false;
+            this.$notify.success({
+              title: "状态修改成功!",
+              message: "",
+            });
+            await this.searchList();
+          } else if (res && res.code >= 100 && res.code <= 104) {
+            await this.logout();
+          } else {
+            this.$message.warning(res.message);
+          }
+        })
+        .catch(() => {
+          console.log("取消");
+        });
+    },
+  },
+};
+</script>
+   <style lang="scss" scoped>
+.nowCount {
+}
+</style>
+   

+ 1 - 1
src/views/stock/stockWarning/addEdit.vue

@@ -42,7 +42,7 @@
               <el-cascader
                 :options="options"
                 v-model="value"
-                :disabled="isDisabled"
+                :disabled="true"
                 placeholder="请输入仓库名称"
                 clearable
                 filterable

+ 22 - 29
src/views/stock/stockWarning/index.vue

@@ -30,26 +30,6 @@
               <el-col :span="24">
                 <!-- 请选择仓库 -->
                 <el-col :span="5" style="width: 160px">
-                  <!-- <el-select
-                    :size="searchSize"
-                    v-model="parmValue.status"
-                    filterable
-                    clearable
-                    placeholder="请选择仓库"
-                    style="width: 100%"
-                    @change="
-                      pageInfo.curr = 1;
-                      parmValue.page = 1;
-                      searchList();
-                    "
-                  >
-                    <el-option
-                      v-for="item in stock"
-                      :key="item.id"
-                      :label="`${item.name}  ${item.id}`"
-                      :value="item.id"
-                    />
-                  </el-select> -->
                   <el-cascader
                     placeholder="请选择仓库"
                     filterable
@@ -76,12 +56,12 @@
                   />
                 </el-col>
                 <!-- 库存量 -->
-                <el-col :span="6" style="width: 352px; padding: 0 0 0 20px">
+                <el-col :span="6" style="width: 312px; padding: 0 0 0 20px">
                   <number-range
                     :start="parmValue.total_low"
                     :end="parmValue.total_up"
                     :type="1"
-                    :width="'150px'"
+                    :width="'120px'"
                     :title="'库存量'"
                     :size="searchSize"
                     @numReturned="numReturned($event, 0)"
@@ -89,7 +69,7 @@
                 </el-col>
 
                 <!-- 预警库存量 -->
-                <el-col :span="6" style="width: 352px; padding: 0 0 0 20px">
+                <el-col :span="6" style="width: 312px; padding: 0 0 0 0px">
                   <number-range
                     :start="parmValue.total_low"
                     :end="parmValue.total_up"
@@ -101,7 +81,7 @@
                   />
                 </el-col>
 
-                <el-col :span="4" style="width: 74px">
+                <el-col :span="4" style="width: 74px" class="mr10">
                   <el-button
                     :size="searchSize"
                     type="primary"
@@ -115,7 +95,11 @@
                 <!-- <el-button>
                   <el-button @click="handClick">testPop</el-button>
                 </el-button> -->
-                <el-col :span="4" style="width: 74px; margin-left: 10px">
+                <el-col
+                  :span="4"
+                  style="width: 74px; margin-left: 10px"
+                  class="mr5"
+                >
                   <el-button
                     :size="searchSize"
                     class="fr"
@@ -180,7 +164,7 @@
             ></i>
           </el-tooltip> -->
 
-          <el-tooltip
+          <!-- <el-tooltip
             v-if="powers.some((item) => item == '007')"
             effect="dark"
             content="详情"
@@ -190,7 +174,7 @@
               class="el-icon-view tb-icon"
               @click="openModal(scope.row.id, true, scope.row)"
             ></i>
-          </el-tooltip>
+          </el-tooltip> -->
           <el-tooltip
             v-if="powers.some((item) => item == '005')"
             effect="dark"
@@ -521,7 +505,16 @@ export default {
 <style lang="scss" scoped>
 .survey {
 }
-
+@media screen and (max-width: 1423px) {
+  .mr5 {
+    margin-top: 8px;
+  }
+}
+@media screen and (max-width: 1337px) {
+  .mr10 {
+    margin-top: 8px;
+  }
+}
 .to {
   float: left;
   height: 32px;
@@ -529,7 +522,7 @@ export default {
   padding-left: 6px;
 }
 .min {
-  min-width: 1600px;
+  min-width: 1050px;
 }
 /**
 import numberRange from "@/components/numberRange";

+ 163 - 157
src/views/stock/survey/index.vue

@@ -17,7 +17,7 @@
               @change="
                 pageInfo.curr = 1;
                 parmValue.page = 1;
-                searchList();
+                stockName();
               "
             ></el-cascader>
 
@@ -82,8 +82,14 @@
           <el-col :span="24" class="card">
             <el-card shadow="always">
               <i :class="item.icon" class="icon"></i>
-              <p>{{ item.num }}</p>
-              <!-- <p>{{ item.label }}</p> -->
+              <!-- <p>{{ item.num }}</p> -->
+              <countTo
+                style="display: block"
+                :startVal="startVal"
+                :endVal="item.endVal"
+                :duration="3000"
+              ></countTo>
+              <p style="margin-top: 5px">{{ item.label }}</p>
             </el-card>
           </el-col>
         </el-row>
@@ -121,7 +127,7 @@
             "
           ></el-tag>
         </template> -->
-        <template #operation="{ scope }">
+        <!-- <template #operation="{ scope }">
           <el-tooltip
             v-if="powers.some((item) => item == '020')"
             effect="dark"
@@ -182,7 +188,7 @@
               @click="statusConfirm(scope.row.id, scope.row.status)"
             ></i>
           </el-tooltip>
-        </template>
+        </template> -->
       </ex-table>
       <add-edit
         :id="modelId"
@@ -210,10 +216,10 @@
 import mixinPage from "@/mixins/elPaginationHandle";
 import resToken from "@/mixins/resToken";
 import ExTable from "@/components/ExTableNew.vue";
-import statusList from "@/assets/js/statusList";
+// import statusList from "@/assets/js/statusList";
 // import asyncRequest from "@/apis/service/stock/stockWarning";
 import asyncRequest from "@/mock/service/stock/survey";
-
+import countTo from "vue-count-to";
 import addEdit from "./addEdit";
 import { mapGetters } from "vuex";
 
@@ -223,6 +229,7 @@ export default {
   components: {
     addEdit,
     ExTable,
+    countTo,
   },
   computed: {
     ...mapGetters(["tablebtnSize", "searchSize", "size"]),
@@ -245,6 +252,7 @@ export default {
       //   { id: "0", label: "禁用" },
       //   { id: "1", label: "启用" },
       // ],
+      startVal: 0, //动态效果显示卡片内的数字数量
       statistics: [],
       sitem: null,
       // nowStock: 20, //当前库存
@@ -254,29 +262,33 @@ export default {
       // roadStock: 10, //在途库存
       stock: [],
       stock_list: [
-        //渲染表格用的
+        //渲染表格上方的卡片选项用的
         {
           id: "1",
           icon: "el-icon-box",
           label: "当前库存",
           num: 0,
+          endVal: 0,
         },
         {
           id: "2",
           icon: "el-icon-download",
           label: "待入库",
+          endVal: 0,
           num: 0,
         },
         {
           id: "3",
           icon: "el-icon-upload2",
           label: "待出库",
+          endVal: 0,
           num: 0,
         },
         {
           id: "4",
           icon: "el-icon-shopping-cart-full",
           label: "可用库存",
+          endVal: 0,
           num: 0,
         },
         {
@@ -284,6 +296,7 @@ export default {
           icon: "el-icon-truck",
           label: "在途库存",
           num: 0,
+          endVal: 0,
         },
       ],
       loading: true,
@@ -291,20 +304,20 @@ export default {
       isDetail: false,
       modelId: 0,
       parmValue: {
-        name: "", // 业务员名字
-        username: "", // 账号
-        status: "", //
-        page: 1, // 页码
-        size: 15, // 每页显示条数
+        //入参参数
+        // name: "", // 业务员名字
+        // username: "", // 账号
+        // status: "", //
+        // page: 1, // 页码
+        // size: 15, // 每页显示条数
       },
-      tableData: [],
+      tableData: [], //渲染表格数据
       passwordModel: false,
       passwordModelId: 0,
       isPasswordDetail: false,
-      // 表格 - 数据
-      tableData: [],
-      // 表格 - 参数
+      tableData: [], // 表格 - 数据
       table: {
+        // 表格 - 参数
         stripe: true,
         border: true,
         _defaultHeader_: ["setcol"],
@@ -315,170 +328,162 @@ export default {
         curr: 1,
         total: 0,
       },
-      // 表格 - 列参数
       columns: [
+        // 表格 - 列参数
         {
-          prop: "nickname",
+          prop: "id",
           label: "记录编号",
         },
         {
-          prop: "role_name",
+          prop: "author",
           label: "操作人",
         },
         {
-          prop: "mobile",
+          prop: "reviewer",
           label: "部门",
         },
         {
-          prop: "email",
+          prop: "type",
           label: "库存类型",
         },
         {
-          prop: "status",
+          prop: "number",
           label: "操作数量",
-          _slot_: "status",
-          width: "80px",
+          // _slot_: "status",
+          // width: "80px",
         },
         {
-          prop: "addtime",
+          prop: "typeo",
           label: "库存来源",
-          sortable: true,
+          // sortable: true,
         },
         {
-          prop: "addtime",
+          prop: "addTime",
           label: "操作时间",
-          sortable: true,
-        },
-        {
-          prop: "",
-          label: "操作",
-          fixed: "right",
-          _noset_: true,
-          _slot_: "operation",
+          // sortable: true,
         },
+        // {
+        //   prop: "",
+        //   label: "操作",
+        //   fixed: "right",
+        //   _noset_: true,
+        //   _slot_: "operation",
+        // },
       ],
       value: [],
-      options: [
-        {
-          value: "",
-          label: "A公司",
-          children: [
-            {
-              value: "",
-              label: "A公司仓库1",
-            },
-            {
-              value: "",
-              label: "A公司仓库2",
-            },
-          ],
-        },
-        {
-          value: "",
-          label: "B公司",
-          children: [
-            {
-              value: "",
-              label: "B公司仓库1",
-            },
-            {
-              value: "",
-              label: "B公司仓库2",
-            },
-          ],
-        },
-        {
-          value: "",
-          label: "C公司",
-          children: [
-            {
-              value: "",
-              label: "C公司仓库1",
-            },
-            {
-              value: "",
-              label: "C公司仓库2",
-            },
-          ],
-        },
-      ],
+      options: [], //用于渲染多级仓库的数据
     };
   },
   mounted() {
-    this.searchList();
-    this.stockList();
+    this.searchList(); //获取表格信息
+    this.stockList(); //获取卡片内库存数据信息
+    this.stockName(); //获取多级仓库列表信息
   },
 
   methods: {
     restSearch() {
-      this.parmValue = {
-        name: "", // 业务员名字
-        username: "", // 账号
-        status: "", //
-        page: 1, // 页码
-        size: 10, // 每页显示条数
-      };
-      this.searchList();
-      // this.stock_list[0].num
+      //清空入参参数
+      // this.parmValue = {
+      //   name: "", // 业务员名字
+      //   username: "", // 账号
+      //   status: "", //
+      //   page: 1, // 页码
+      //   size: 10, // 每页显示条数
+      // };
+      // this.searchList();
+      // // this.stock_list[0].num
     },
 
     openModal(id, isDetail, sitem) {
+      //打开弹窗
       this.showModel = true;
       this.modelId = id;
       this.isDetail = isDetail;
       this.sitem = sitem;
     },
     async deleteById(id, status) {
-      await this.$confirm("确定要删除?", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning",
-      })
-        .then(async () => {
-          const model = {
-            id: id,
-            status: status === "1" ? "0" : "1",
-          };
-          const res = await asyncRequest.status(model);
-          if (res && res.code === 0) {
-            this.$notify.success({
-              title: "删除成功",
-              message: "",
-            });
-            this.searchList();
-          } else if (res && res.code >= 100 && res.code <= 104) {
-            await this.logout();
-          } else {
-            this.$message.warning(res.message);
-          }
-        })
-        .catch(() => {
-          console.log("取消");
-        });
+      //删除功能
+      // await this.$confirm("确定要删除?", {
+      //   confirmButtonText: "确定",
+      //   cancelButtonText: "取消",
+      //   type: "warning",
+      // })
+      //   .then(async () => {
+      //     const model = {
+      //       id: id,
+      //       status: status === "1" ? "0" : "1",
+      //     };
+      //     const res = await asyncRequest.status(model);
+      //     if (res && res.code === 0) {
+      //       this.$notify.success({
+      //         title: "删除成功",
+      //         message: "",
+      //       });
+      //       this.searchList();
+      //     } else if (res && res.code >= 100 && res.code <= 104) {
+      //       await this.logout();
+      //     } else {
+      //       this.$message.warning(res.message);
+      //     }
+      //   })
+      //   .catch(() => {
+      //     console.log("取消");
+      //   });
     },
     async stockList() {
-      console.log(this.stock_list);
+      //获取表格上方的卡片数据
+      // console.log(this.stock_list);
       const res1 = await asyncRequest.statistics(this.parmValue);
-      console.log(res1.data);
+      // console.log(res1.data);
       const { value1, value2, value3, value4, value5 } = res1.data;
       this.stock.push(value1, value2, value3, value4, value5);
-      console.log(this.stock);
+      // this.endVal = value1;
+      // console.log(this.stock);
       // console.log(this.stock_list[5].num);
-      for (let i = 0; i <= this.stock_list.length; i++) {
-        //  = this.stock[i];
-        console.log(this.stock_list[i].num);
+      for (let i = 0; i <= this.stock_list.length - 1; i++) {
+        // this.stock_list[i].num = this.stock[i];
+        this.stock_list[i].endVal = this.stock[i];
       }
       // console.log(this.stock_list);
     },
+    async stockName() {
+      //获取多级仓库名称的方法
+      const res = await asyncRequest.listAll(this.parmValue);
+      // console.log(res.data);
+      // this.options = res.data;
+      // console.log(this.options);
+      let arr = res.data;
+      // console.log(arr);
+      arr.forEach((ele) => {
+        let item = {
+          value: ele.id,
+          label: ele.name,
+          children: [],
+        };
+        ele.child.forEach((elem) => {
+          let model = {
+            value: ele.id,
+            label: ele.name,
+          };
+          item.children.push(model);
+        });
+        this.options.push(item);
+      });
+      console.log(this.options);
+      // console.log(this.pageInfo.total);
+    },
     async searchList() {
+      //获取表格数据
       this.loading = true;
-      const res = await asyncRequest.list(this.parmValue);
-      // const res = await asyncRequest.log(this.parmValue);
-      // console.log(res.data);
+      // const res = await asyncRequest.list(this.parmValue);
+      const res = await asyncRequest.log(this.parmValue);
+      // console.log(res);
       if (res && res.code === 0 && res.data) {
-        this.tableData = res.data;
-        // console.log(this.tableData);
+        // this.tableData = res.data;
+        this.tableData = res.data.list;
         this.pageInfo.total = Number(res.data.count);
+        // console.log(this.tableData);
+        // this.pageInfo.total = Number(res.data.count);
       } else if (res && res.code >= 100 && res.code <= 104) {
         await this.logout();
       } else {
@@ -489,35 +494,36 @@ export default {
     },
 
     async statusConfirm(id, status) {
-      let str = status === "1" ? "禁用" : "启用";
-      await this.$confirm("确定要改为" + str + "?", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning",
-      })
-        .then(async () => {
-          this.loading = true;
-          const model = {
-            id: id,
-            status: status === "1" ? "0" : "1",
-          };
-          const res = await asyncRequest.status(model);
-          if (res && res.code === 0) {
-            this.loading = false;
-            this.$notify.success({
-              title: "状态修改成功!",
-              message: "",
-            });
-            await this.searchList();
-          } else if (res && res.code >= 100 && res.code <= 104) {
-            await this.logout();
-          } else {
-            this.$message.warning(res.message);
-          }
-        })
-        .catch(() => {
-          console.log("取消");
-        });
+      //启用禁用状态
+      // let str = status === "1" ? "禁用" : "启用";
+      // await this.$confirm("确定要改为" + str + "?", {
+      //   confirmButtonText: "确定",
+      //   cancelButtonText: "取消",
+      //   type: "warning",
+      // })
+      //   .then(async () => {
+      //     this.loading = true;
+      //     const model = {
+      //       id: id,
+      //       status: status === "1" ? "0" : "1",
+      //     };
+      //     const res = await asyncRequest.status(model);
+      //     if (res && res.code === 0) {
+      //       this.loading = false;
+      //       this.$notify.success({
+      //         title: "状态修改成功!",
+      //         message: "",
+      //       });
+      //       await this.searchList();
+      //     } else if (res && res.code >= 100 && res.code <= 104) {
+      //       await this.logout();
+      //     } else {
+      //       this.$message.warning(res.message);
+      //     }
+      //   })
+      //   .catch(() => {
+      //     console.log("取消");
+      //   });
     },
   },
 };