Qukatie 2 anos atrás
pai
commit
e79c330974
2 arquivos alterados com 199 adições e 29 exclusões
  1. 85 7
      src/views/client/index.vue
  2. 114 22
      src/views/product/index.vue

+ 85 - 7
src/views/client/index.vue

@@ -59,7 +59,11 @@
       </table>
       <el-row>
         <el-col :span="4">
-          <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:73vh;" />
+          <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:73vh;" @save="corpTypeVisible = true">
+            <template slot="addBtn">
+              <i class="el-icon-plus" style="font-size:18px;line-height: 30px;width: 20px;padding: 0 10px;" @click="corpTypeVisible = true"></i>
+            </template>
+          </avue-tree>
         </el-col>
         <el-col :span="20">
           <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search"
@@ -113,6 +117,17 @@
     </basic-container>
     <details-page v-if="!show" @goBack="goBack()" :detailData="detailData" />
     <details-info v-if="!showInfo" @goBack="goBack()" :detailData="detailData" />
+    <el-dialog title="添加客户分类" v-dialogDrag :visible.sync="corpTypeVisible" class="avue-dialog avue-dialog--top"
+      width="30%" append-to-body @closed="corpTypeClosed">
+      <span>
+        <avue-form :key="reload" ref="corpType" v-model="form4" :option="option4" style="margin-top:20px">
+        </avue-form>
+      </span>
+      <div class="avue-dialog__footer">
+        <el-button @click="corpTypeVisible = false" size="mini">取 消</el-button>
+        <el-button @click="addCorpType" type="primary" size="mini">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
   
@@ -120,11 +135,12 @@
 import detailsInfo from "./detailsInfo";
 import detailsPage from "./detailsPage";
 import { option } from "./js/optionList";
-import { getList, getCorpType, pageStatistics, remove } from "@/api/basicData/client";
+import { getList, getCorpType, pageStatistics, remove, addCorpType, customerList } from "@/api/basicData/client";
 export default {
   name: "index",
   data() {
     return {
+      corpTypeVisible: false,
       src: '',
       show: true,
       showInfo: true,
@@ -178,8 +194,8 @@ export default {
             text: '当季',
             onClick(picker) {
               const date = new Date();
-              const start = new Date(date.getFullYear(),parseInt(date.getMonth()/3)*3, 1, 0, 0, 0);
-              const end = new Date(date.getFullYear(),parseInt(date.getMonth()/3)*3+3, 0, 23, 59, 59);
+              const start = new Date(date.getFullYear(), parseInt(date.getMonth() / 3) * 3, 1, 0, 0, 0);
+              const end = new Date(date.getFullYear(), parseInt(date.getMonth() / 3) * 3 + 3, 0, 23, 59, 59);
               picker.$emit('pick', [start, end]);
             }
           }, {
@@ -202,7 +218,7 @@ export default {
             text: '最近二周',
             onClick(picker) {
               const date = new Date();
-              const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7*2, 0, 0, 0);
+              const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7 * 2, 0, 0, 0);
               const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
               picker.$emit('pick', [start, end]);
             }
@@ -210,7 +226,7 @@ export default {
             text: '最近三周',
             onClick(picker) {
               const date = new Date();
-              const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7*3, 0, 0, 0);
+              const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7 * 3, 0, 0, 0);
               const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
               picker.$emit('pick', [start, end]);
             }
@@ -226,7 +242,37 @@ export default {
           value: "value",
         }
       },
-      treeData: []
+      treeData: [],
+      form4: {},
+      option4: {
+        menuBtn: false,
+        labelWidth: 80,
+        column: [
+          {
+            label: "分类名称",
+            prop: "cname",
+            rules: [
+              {
+                required: true,
+                message: "",
+                trigger: "blur"
+              }
+            ],
+            span: 24,
+          },
+          {
+            label: "上级类型",
+            prop: "parentId",
+            dicData: [],
+            type: "tree",
+            props: {
+              label: "cname",
+              value: "id"
+            },
+            span: 24,
+          }
+        ]
+      },
     };
   },
   components: {
@@ -256,6 +302,9 @@ export default {
       getCorpType({ corpType: 'KH' }).then(res => {
         this.treeData = res.data.data
       });
+      customerList({ corpType: "KH" }).then(res => {
+        this.findObject(this.option4.column, "parentId").dicData = res.data.data.records
+      });
       this.$refs.crud.init();
     },
     searchCriteriaSwitch(type) {
@@ -306,6 +355,25 @@ export default {
           this.loading = false;
         });
     },
+    addCorpType() {
+      this.$refs["corpType"].validate((valid, done) => {
+        done();
+        if (valid) {
+          addCorpType({ ...this.form4, corpType: 'KH', status: 0 })
+            .then(res => {
+              this.$message.success("保存成功");
+              this.getAllWorkDicts()
+              this.corpTypeVisible = false
+            })
+        } else {
+          return false;
+        }
+      });
+    },
+    corpTypeClosed() {
+      this.reload = Math.random();
+      this.form4 = this.$options.data().form4
+    },
     viewInfo(row) {
       this.detailData = {
         id: row.id,
@@ -386,6 +454,16 @@ export default {
   height: 94.2vh;
 }
 
+::v-deep .el-form-item__error {
+  display: none !important;
+}
+::v-deep .el-input-group__append{
+  padding: 0 0px !important;
+}
+.el-dialog ::v-deep .el-form-item__error {
+  display: none !important;
+}
+
 .stat-td {
   text-align: center;
   position: relative;

+ 114 - 22
src/views/product/index.vue

@@ -1,23 +1,32 @@
 <template>
   <div>
     <basic-container v-show="show" class="page-crad">
-      <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search"
-        @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
-        @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
-        @resetColumn="resetColumn" :cell-style="cellStyle" @search-criteria-switch="searchCriteriaSwitch">
-        <template slot="menuLeft">
-          <el-button type="primary" size="mini" @click.stop="newAdd()">新建产品
-          </el-button>
-        </template>
-        <template slot-scope="{ row, index }" slot="cname">
-          <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 2)">{{ row.cname }}
-          </span>
-        </template>
-        <template slot-scope="{ row, index }" slot="menu">
-          <el-tooltip class="item" effect="dark" content="删除" placement="top">
-            <i class="tradingIcon icon-del" @click.stop="rowDel(row, index)" v-if="row.status != 0" />
-          </el-tooltip>
-          <!-- <el-tooltip class="item" effect="dark" content="新建销售订单" placement="top">
+      <el-row>
+        <el-col :span="4">
+          <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:73vh;">
+            <template slot="addBtn">
+              <i class="el-icon-plus" @click="goodsTypeVisible= true" style="font-size:18px;line-height: 30px;width: 20px;padding: 0 10px;"></i>
+            </template>
+          </avue-tree>
+        </el-col>
+        <el-col :span="20">
+          <avue-crud ref="crud" :option="option" :data="dataList" :page.sync="page" :search.sync="search"
+            @search-change="searchChange" @current-change="currentChange" @size-change="sizeChange"
+            @refresh-change="refreshChange" @on-load="onLoad" :table-loading="loading" @saveColumn="saveColumn"
+            @resetColumn="resetColumn" :cell-style="cellStyle" @search-criteria-switch="searchCriteriaSwitch">
+            <template slot="menuLeft">
+              <el-button type="primary" size="mini" @click.stop="newAdd()">新建产品
+              </el-button>
+            </template>
+            <template slot-scope="{ row, index }" slot="cname">
+              <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 2)">{{ row.cname }}
+              </span>
+            </template>
+            <template slot-scope="{ row, index }" slot="menu">
+              <el-tooltip class="item" effect="dark" content="删除" placement="top">
+                <i class="tradingIcon icon-del" @click.stop="rowDel(row, index)" v-if="row.status != 0" />
+              </el-tooltip>
+              <!-- <el-tooltip class="item" effect="dark" content="新建销售订单" placement="top">
             <i class="tradingIcon icon-add" />
           </el-tooltip>
           <el-tooltip class="item" effect="dark" content="编辑" placement="top">
@@ -32,27 +41,41 @@
           <el-tooltip class="item" effect="dark" content="对账" placement="top">
             <i class="tradingIcon icon-reconciliation" />
           </el-tooltip> -->
-          <!-- <el-button type="text" size="small" @click.stop="editOpen(row, 2)">
+              <!-- <el-button type="text" size="small" @click.stop="editOpen(row, 2)">
             查看
           </el-button>
           <el-button type="text" size="small" @click.stop="rowDel(row, index)">
             删除
           </el-button> -->
-        </template>
-      </avue-crud>
+            </template>
+          </avue-crud>
+        </el-col>
+      </el-row>
     </basic-container>
     <details-page v-if="!show" @goBack="goBack()" :detailData="detailData" />
+    <el-dialog title="添加产品分类" v-dialogDrag :visible.sync="goodsTypeVisible" class="avue-dialog avue-dialog--top"
+        width="30%" append-to-body @closed="goodsTypeClosed">
+        <span>
+          <avue-form :key="reload" ref="goodsType" v-model="form2" :option="option2" style="margin-top:20px">
+          </avue-form>
+        </span>
+        <div class="avue-dialog__footer">
+          <el-button @click="goodsTypeVisible = false" size="mini">取 消</el-button>
+          <el-button @click="saveGoodstype" type="primary" size="mini">确 定</el-button>
+        </div>
+      </el-dialog>
   </div>
 </template>
   
 <script>
 import detailsPage from "./detailsPage";
 import { option } from "./js/optionList";
-import { getList, remove, getAllgoods } from "@/api/basicData/product";
+import { getList, remove, getAllgoods,getGoodstype,goodsTypesubmit } from "@/api/basicData/product";
 export default {
   name: "index",
   data() {
     return {
+      goodsTypeVisible:false,
       src: '',
       show: true,
       loading: false,
@@ -67,6 +90,47 @@ export default {
         pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
       },
       option: {},
+      treeData: [],
+      form2: {},
+      option2: {
+        menuBtn: false,
+        labelWidth: 80,
+        column: [
+          {
+            label: "分类名称",
+            prop: "cname",
+            rules: [
+              {
+                required: true,
+                message: "",
+                trigger: "blur"
+              }
+            ],
+            span: 24,
+          },
+          {
+            label: "上级类型",
+            prop: "parentId",
+            dicData: [],
+            type: "tree",
+            props: {
+              label: "title",
+              value: "id"
+            },
+            span: 24,
+          }
+        ]
+      },
+      treeOption: {
+        addBtn: false,
+        menu: false,
+        size: "small",
+        props: {
+          labelText: "标题",
+          label: "title",
+          value: "value",
+        }
+      },
     };
   },
   components: {
@@ -96,6 +160,10 @@ export default {
       getAllgoods().then(res => {
         this.findObject(this.option.column, "cname").dicData = res.data.data
       });
+      getGoodstype().then(res => {
+        this.treeData= res.data.data;
+        this.findObject(this.option2.column, "parentId").dicData = res.data.data;
+      });
       this.$refs.crud.init();
     },
     searchCriteriaSwitch(type) {
@@ -121,6 +189,28 @@ export default {
     newAdd() {
       this.show = false;
     },
+    saveGoodstype() {
+      this.$refs["goodsType"].validate((valid, done) => {
+        done();
+        if (valid) {
+          goodsTypesubmit({ ...this.form2, status: 0 }).then(res => {
+            this.getAllWorkDicts()
+          })
+          this.goodsTypeVisible = false
+        } else {
+          return false;
+        }
+      });
+    },
+    goodsTypeClosed() {
+      this.reload = Math.random();
+      this.form2 = this.$options.data().form2
+    },
+    nodeClick(data) {
+      this.search.goodsTypeId = data.value
+      this.page.currentPage = 1;
+      this.onLoad(this.page, this.search);
+    },
     onLoad(page, params = {}) {
       let data = this.deepClone(Object.assign(params, this.search));
       this.loading = true;
@@ -208,7 +298,9 @@ export default {
 .page-crad ::v-deep .basic-container__card {
   height: 94.2vh;
 }
-
+::v-deep .el-input-group__append{
+  padding: 0 0px !important;
+}
 .stat-td {
   text-align: center;
   position: relative;