From e5c21244bd817fc2dd62ef38facc9b959bde9ee3 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Mon, 20 Nov 2023 17:44:38 +0800
Subject: [PATCH] 标签代码优化

---
 src/views/userHouse/lable/statistics.vue |   98 +++++++++++
 src/views/userHouse/lable/list.vue       |  177 +++++++++++++++++++++
 src/api/label/label.js                   |    2 
 src/views/userHouse/lable/household.vue  |  165 +++++++++++++++++++
 src/views/system/menu.vue                |    4 
 5 files changed, 429 insertions(+), 17 deletions(-)

diff --git a/src/api/label/label.js b/src/api/label/label.js
index fad536f..31d2fac 100644
--- a/src/api/label/label.js
+++ b/src/api/label/label.js
@@ -9,7 +9,7 @@
 }
 export const getList = (current, size, params) => {
   return request({
-    url: '/api/blade-label/label/page',
+    url: '/api/blade-label/label/list',
     method: 'get',
     params: {
       ...params,
diff --git a/src/views/system/menu.vue b/src/views/system/menu.vue
index fcfd2e1..a931424 100644
--- a/src/views/system/menu.vue
+++ b/src/views/system/menu.vue
@@ -98,7 +98,7 @@
               prop: "parentId",
               type: "tree",
               dicData: [],
-              hide: true,
+              // hide: true,
               addDisabled: false,
               props: {
                 label: "title",
@@ -228,7 +228,7 @@
                 value: 'id'
               },
               multiple: true,
-              hide: true
+              // hide: true
             }
           ]
         },
diff --git a/src/views/userHouse/lable/household.vue b/src/views/userHouse/lable/household.vue
index 4711ae1..44c7602 100644
--- a/src/views/userHouse/lable/household.vue
+++ b/src/views/userHouse/lable/household.vue
@@ -1,11 +1,164 @@
 <template>
-  <div id="">
-    222222222222
+  <div style="width:400px">
+
+    <el-row>
+      <el-col style="color: red;" :span="24">
+        注意:仅导入未添加过标签的住户
+        EXCEL格式:小区id,姓名,手机,身份证,标签id,
+        颜色(1-绿 2-黄 3-红),备注
+      </el-col>
+    </el-row>
+    <basicContainer>
+      <el-dialog title="标签住户导入" append-to-body :visible.sync="excelBox" width="555px">
+        <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
+          <template slot="excelTemplate">
+            <el-button type="primary" @click="handleTemplate">
+              点击下载<i class="el-icon-download el-icon--right"></i>
+            </el-button>
+          </template>
+        </avue-form>
+      </el-dialog>
+
+      <el-button type="primary" @click="handleExcel">标签住户导入 excel</el-button>
+
+    </basicContainer>
+
+
   </div>
 </template>
-
 <script>
-</script>
+  import {
+    exportBlob
+  } from "@/api/common";
+  import {
+    getToken
+  } from '@/util/auth';
+  import {
+    downloadXls
+  } from "@/util/util";
+  export default {
+    data() {
+      return {
+        excelBox: false,
+        excelForm: {},
+        excelOption: {
+          submitBtn: false,
+          emptyBtn: false,
+          column: [{
+              label: '模板上传',
+              prop: 'excelFile',
+              type: 'upload',
+              drag: true,
+              loadText: '模板上传中,请稍等',
+              span: 24,
+              propsHttp: {
+                res: 'data'
+              },
+              tip: '请上传 .xls,.xlsx 标准格式文件',
+              action: "/api/blade-householdLabel/householdLabel/import-userHouseLabel"
+            },
+            // {
+            //   label: "数据覆盖",
+            //   prop: "isCovered",
+            //   type: "switch",
+            //   align: "center",
+            //   width: 80,
+            //   dicData: [{
+            //       label: "否",
+            //       value: 0
+            //     },
+            //     {
+            //       label: "是",
+            //       value: 1
+            //     }
+            //   ],
+            //   value: 0,
+            //   slot: true,
+            //   rules: [{
+            //     required: true,
+            //     message: "请选择是否覆盖",
+            //     trigger: "blur"
+            //   }]
+            // },
+            {
+              label: '模板下载',
+              prop: 'excelTemplate',
+              formslot: true,
+              span: 24,
+            }
+          ]
+        }
+      }
+    },
+    methods: {
+      handleExcel() {
+        this.excelBox = true;
 
-<style>
-</style>
+        // let opt = {
+        //   title: '标签住户导入',
+        //   column: [{
+        //     label: '门牌地址编码',
+        //     prop: 'title'
+        //   }, {
+        //     label: '标签ID',
+        //     prop: 'title'
+        //   }, {
+        //     label: '标签名称',
+        //     prop: 'title'
+        //   }, {
+        //     label: '颜色',
+        //     prop: 'title'
+        //   }, {
+        //     label: '备注',
+        //     prop: 'title'
+        //   }, {
+        //     label: '用户id',
+        //     prop: 'title'
+        //   }, {
+        //     label: '住户id',
+        //     prop: 'title'
+        //   }],
+        //   data: []
+        // }
+        // this.$Export.excel({
+        //   title: opt.title,
+        //   columns: opt.column,
+        //   data: opt.data
+        // });
+      },
+      handleExcel1() {
+        let opt = {
+          title: '文档标题',
+          column: [{
+            label: '多级表头',
+            prop: 'header',
+            children: [{
+              label: '标题1',
+              prop: 'title1'
+            }, {
+              label: '标题2',
+              prop: 'title2'
+            }]
+          }],
+          data: [{
+            title1: "测试数据1",
+            title2: "测试数据2"
+          }, {
+            title1: "测试数据2",
+            title2: "测试数据2"
+          }]
+        }
+        this.$Export.excel({
+          title: opt.title,
+          columns: opt.column,
+          data: opt.data
+        });
+      },
+      handleTemplate() {
+        exportBlob(`/api/blade-householdLabel/householdLabel/export-userHouseLabel?${this.website.tokenHeader}=${getToken()}`).then(res => {
+          downloadXls(res.data, "标签住户数据模板.xlsx");
+        })
+      },
+    }
+  }
+</script>
diff --git a/src/views/userHouse/lable/list.vue b/src/views/userHouse/lable/list.vue
index 4a0d30b..a48682e 100644
--- a/src/views/userHouse/lable/list.vue
+++ b/src/views/userHouse/lable/list.vue
@@ -1,11 +1,180 @@
 <template>
-  <div id="">
-    111111111111111111
-  </div>
-</template>
+ <el-row>
+   <el-col :span="24">
+     <basicContainer>
+       <avue-crud ref="crud" :option="option" :before-open="beforeOpen" :before-close="beforeClose" :data="data"
+         @tree-load="treeLoad" @row-save="rowSave" @row-del="rowDel" @refresh-change="refreshChange" @row-update="rowUpdate"
+         @on-load="onLoad">
+         <template #menu="{row,size}">
+           <el-button :size="size" type="text" icon="el-icon-circle-plus-outline" size="small" @click="handleAdd(row)">新增子级
+           </el-button>
+         </template>
+       </avue-crud>
+     </basicContainer>
+   </el-col>
 
+ </el-row>
+</template>
 <script>
+  import {
+    getTreeList,
+    add,
+    update,
+    remove
+  } from '@/api/label/label'
+
+  export default {
+    data() {
+      return {
+        query: {
+          parentId: 0
+        },
+        data: [],
+        loading: true,
+        page: {
+          pageSize: 10,
+          currentPage: 1,
+          total: 0
+        },
+        parentId: undefined,
+        option: {
+          lazy: true,
+          rowKey: 'id',
+          defaultExpandAll:true,
+          column: [{
+            label: '名称',
+            prop: 'name'
+          }, {
+            label: 'ID',
+            prop: 'id',
+            display: false
+          }, {
+            label: '排序',
+            prop: 'sort',
+          }, {
+            label: '父级id',
+            prop: 'parentId',
+            type: "tree",
+            dicData: [],
+            hide: true,
+            addDisabled: false,
+            props: {
+              label: "name",
+              value: 'id'
+            },
+          }]
+        },
+        data1: [],
+        selectionList: [],
+      }
+    },
+
+    methods: {
+
+      refreshChange() {
+        this.onLoad();
+      },
+
+      beforeOpen(done, type) {
+        if (["add", "edit"].includes(type)) {
+          this.initData();
+        }
+        done();
+      },
+
+      beforeClose(done) {
+        this.parentId = "";
+        const column = this.findObject(this.option.column, "parentId");
+        column.value = "";
+        column.addDisabled = false;
+        done();
+      },
+
+      initData() {
+        const column = this.findObject(this.option.column, "parentId");
+        column.dicData = this.data;
+      },
+
+      selectionClear() {
+        this.selectionList = [];
+      },
+
+      onLoad(page, params = {}) {
+        this.loading = true;
+        getTreeList().then(res => {
+          const data = res.data.data;
+          this.data = data;
+          this.loading = false;
+          this.selectionClear();
+        });
+      },
+
+      rowDel(row, index, done) {
+        console.log("*************")
+        this.$confirm("确定将选择数据删除?", {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning"
+          })
+          .then(() => {
+            return remove(row.id);
+          })
+          .then(() => {
+            this.$message({
+              type: "success",
+              message: "操作成功!"
+            });
+            done(row);
+          });
+      },
+
+      rowSave(row, done) {
+        row.parentId = this.parentId;
+        row.labelName = row.name
+        add(row).then(() => {
+          this.initFlag = false;
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          done();
+        }, error => {
+          window.console.log(error);
+          loading();
+        });
+      },
+
+      rowUpdate(row, index, done) {
+        const column = this.findObject(this.option.column, "parentId");
+        column.value = row.id;
+        done(row)
+      },
+
+      handleAdd(row) {
+        const column = this.findObject(this.option.column, "parentId");
+        column.value = row.id;
+        column.addDisabled = true;
+        this.parentId = row.id
+        this.$refs.crud.rowAdd()
+      },
+
+      treeLoad(tree, treeNode, resolve) {
+        setTimeout(() => {
+          resolve([{
+            id: new Date().getTime(),
+            date: '2016-05-01',
+            name: '王小虎',
+            address: '上海市普陀区金沙江路 1519 弄',
+            hasChildren: true
+          }])
+        }, 1000)
+      }
+    }
+  }
 </script>
 
+
+
 <style>
 </style>
diff --git a/src/views/userHouse/lable/statistics.vue b/src/views/userHouse/lable/statistics.vue
index 2f0d849..41f6706 100644
--- a/src/views/userHouse/lable/statistics.vue
+++ b/src/views/userHouse/lable/statistics.vue
@@ -1,11 +1,101 @@
 <template>
-  <div id="">
-    333333333333
-  </div>
-</template>
+  <!-- <avue-data-box :option="option"></avue-data-box> -->
 
+  <!-- <div v-for="item in items" :key="item.id"> -->
+  <div id="">
+
+    <div id="" v-for="(item,index) in 10">
+      <el-row>
+        <el-col :span="24">
+          <div class="grid-content bg-purple-dark">
+            <el-tag type="danger">标签五</el-tag>
+          </div>
+        </el-col>
+      </el-row>
+
+      <el-row>
+        <el-col :span="24">
+          <div class="grid-content bg-purple-dark">
+            <el-divider content-position="left">少年包青天</el-divider>
+          </div>
+        </el-col>
+      </el-row>
+
+     <!-- <el-row :gutter="20">
+        <el-col :span="6">
+          <div class="grid-content bg-purple"></div>
+        </el-col>
+        <el-col :span="6">
+          <div class="grid-content bg-purple"></div>
+        </el-col>
+        <el-col :span="6">
+          <div class="grid-content bg-purple"></div>
+        </el-col>
+        <el-col :span="6">
+          <div class="grid-content bg-purple"></div>
+        </el-col>
+      </el-row> -->
+
+      <div id="" v-for="(item,index) in 10" style="display: flex;">
+        <div id="">
+          {{index}}
+        </div>
+      </div>
+
+
+    </div>
+
+  </div>
+
+  <!-- </div> -->
+
+</template>
 <script>
+  export default {
+    data() {
+      return {
+        items: [],
+        option: {
+          span: 4,
+          data: []
+        },
+      }
+    }
+  }
 </script>
 
 <style>
+ /* .el-row {
+    margin-bottom: 20px;
+
+    &:last-child {
+      margin-bottom: 0;
+    }
+  }
+
+  .el-col {
+    border-radius: 4px;
+  }
+
+  .bg-purple-dark {
+    background: #99a9bf;
+  }
+
+  .bg-purple {
+    background: #d3dce6;
+  }
+
+  .bg-purple-light {
+    background: #e5e9f2;
+  }
+
+  .grid-content {
+    border-radius: 4px;
+    min-height: 36px;
+  }
+
+  .row-bg {
+    padding: 10px 0;
+    background-color: #f9fafc;
+  } */
 </style>

--
Gitblit v1.9.3