Ver código fonte

update src/views/Esm/Esmcompany.vue.

Signed-off-by: 赵蒙蒙 <1595784580@qq.com>
赵蒙蒙 3 anos atrás
pai
commit
5315121444
1 arquivos alterados com 239 adições e 135 exclusões
  1. 239 135
      src/views/Esm/Esmcompany.vue

+ 239 - 135
src/views/Esm/Esmcompany.vue

@@ -58,10 +58,10 @@
           >
         </div>
         <el-table
+          ref="expandTable"
           :data="ztreeNodes"
           style="width: 100%"
           row-key="id"
-          ref="table"
           border
           :tree-props="{ children: 'children', hasChildren: 'hasChilkdren' }"
           :header-cell-style="{
@@ -70,14 +70,21 @@
             color: '#606266',
           }"
           size="small"
+          @row-click="handleRowClick"
         >
           <el-table-column prop="name" label="部门管理"> </el-table-column>
-
           <el-table-column prop="id" label="编号" width="180">
           </el-table-column>
           <el-table-column prop="address" label="状态" width="180">
             <template slot-scope="scope">
-              <el-button type="primary" plain size="mini">正常</el-button>
+              <el-tag v-if="scope.row.openQuote == '1'" type="primary"
+                >开启</el-tag
+              >
+              <el-tag
+                v-if="scope.row.openQuote == '0' || scope.row.openQuote == null"
+                type="success"
+                >关闭</el-tag
+              >
             </template>
           </el-table-column>
           <el-table-column prop="createTime" label="创建时间">
@@ -117,12 +124,12 @@
       :title="dialogTitle"
       :visible.sync="dialogVisible"
       width="900px"
-      :before-close="handleClose"
       @close="closeVisible"
+      :close-on-click-modal="false"
     >
       <el-form
         :model="dataForm"
-        :rules="dataFormRules"
+        :rules="rules"
         ref="dataForm"
         label-width="120px"
         size="small"
@@ -135,9 +142,16 @@
               :options="areaList"
               :props="optionProps"
               @change="areaHandleChange"
+            ></el-cascader>
+            <!-- <el-cascader
+              size="small"
+              v-model="area"
+              :options="areaList"
+              :props="optionProps"
+              @change="areaHandleChange"
               filterable
               clearable
-            ></el-cascader>
+            ></el-cascader> -->
           </el-form-item>
         </el-row>
         <el-row>
@@ -184,7 +198,7 @@
         </el-row>
         <el-row>
           <el-col :span="24">
-            <el-form-item label="logo:" style="width: 100%">
+            <el-form-item label="logo" style="width: 100%; height: 150px">
               <el-upload
                 style="width: 150px; width: 150px"
                 action="#"
@@ -194,6 +208,7 @@
                 :file-list="imgList1"
                 ref="upload1"
                 :limit="1"
+                :class="{ disabled: uploadDisabled }"
               >
                 <i slot="default" class="el-icon-plus"></i>
                 <div slot="file" slot-scope="{ file }">
@@ -241,14 +256,20 @@
             </el-form-item>
           </el-col>
         </el-row>
+        <el-row>
+          <el-form-item
+            style="margin-left: 600px; margin-bottom: -4px; margin-top: 30px"
+          >
+            <el-button @click="dialogVisible = false">取消</el-button>
+            <el-button type="primary" @click="submitForm('dataForm')"
+              >确 定</el-button
+            >
+          </el-form-item>
+        </el-row>
       </el-form>
 
-      <span slot="footer" class="dialog-footer">
-        <el-button size="small" @click="dialogVisible = false">取 消</el-button>
-        <el-button size="small" type="primary" @click="submitForm"
-          >确 定</el-button
-        >
-      </span>
+      <!-- <span slot="footer" class="dialog-footer">
+      </span> -->
     </el-dialog>
   </div>
 </template>
@@ -260,6 +281,7 @@ import KtCommonTable from "@/views/Core/KtCommonTable.vue"; //表格组件
 // import CommonUtil from "@/utils/comutil.js";
 import { pathToBase64, base64ToPath } from "@/common/image-tools-base64.js";
 import citydata from "@/assets/js/citydata.js";
+import Cookies from "js-cookie";
 
 // import { format  } from "@/utils/datetime"
 export default {
@@ -339,13 +361,17 @@ export default {
         remark: "", //备注
         orderNum: 0,
         logo: "",
-        openQuote: "",
+        openQuote: 0, //状态0为关闭,1为开启
         cnName: "", //拼音
       },
       imgList1: [],
-      dataFormRules: {
+      rules: {
         id: [
-          { required: true, message: "请生成保险公司编码", trigger: "blur" },
+          {
+            required: true,
+            message: "请选择地区生成保险公司编码",
+            trigger: "blur",
+          },
           {
             pattern: /^[0-9a-zA-Z]+$/,
             message: "编码只可包含字母和数字",
@@ -364,36 +390,47 @@ export default {
       area: [],
       optionProps: {
         //配置节点
-        checkStrictly: true,
+        // checkStrictly: true,
         value: "code",
         label: "name",
         children: "sub",
+        expandTrigger:"hover"
       },
       searchForm: {
         classname: "",
         status: "",
       },
       isshow: false,
+      // 是否禁用上传
+      uploadDisabled: false,
+      //点击表格展开折叠
+      expanded: false,
     };
   },
   mounted() {
     this.findLeftTreeData();
     //用像素初始化左边的split的宽度
     // this.changeTreeWidth(240); // 初始化树的宽度
+    this.ztreeNodes.forEach((val) => {
+      this.$set(val, "expanded", false);
+    });
   },
   methods: {
-    handleNodeClick() {},
     // 搜索
     searchInfor() {
       this.findLeftTreeData();
     },
     // 遍历表格数据
     forTableData(arr, isExpand) {
+      console.log(arr)
       arr.forEach((i) => {
-        this.$refs.table.toggleRowExpansion(i, isExpand);
+        console.log(this.$refs.expandTable)
+        this.$refs.expandTable.toggleRowExpansion(i, isExpand);
         if (i.children) {
+          console.log('kkk')
           this.forTableData(i.children, isExpand);
         }
+        
       });
     },
     //展开收起树列表
@@ -414,13 +451,14 @@ export default {
     },
     //删除图片
     handleRemove1(file) {
-      console.log(file);
       this.imgList1.map((ele, index) => {
         if (ele.uid === file.uid) {
           this.imgList1.splice(index, 1);
         }
         return ele;
       });
+      this.uploadDisabled = false;
+      this.dataForm.logo = "";
     },
     /**Split 开始 */
     changeTreeWidth(widthVal) {
@@ -458,11 +496,13 @@ export default {
     //-- tree end-------
     //影像上传方法
     drivingupload1(file) {
+      // console.log(file);
       this.imgList1 = [];
       pathToBase64(file.url).then((path) => {
         this.dataForm.logo = path;
         this.imgList1.push({ url: path });
       });
+      this.uploadDisabled = true;
     },
     // 右侧列表的方法Start
     findPage(data) {
@@ -477,31 +517,53 @@ export default {
         })
         .then(data != null ? data.callback : "");
     },
-    // 右侧列表的方法End
     areaHandleChange(value) {
       if (value != "") {
         this.dataForm.id =
-          this.currentTreeNode.id.substring(0, 6) + value[value.length - 1];
+          this.dataForm.parentId.substring(0, 6) + value[value.length - 1];
       } else {
         this.dataForm.id = "";
       }
+      // this.$refs.cascaderHandle.dropDownVisible = false;
+
+
+
+      // if (this.$refs.refHandle) {
+      //   this.$refs.refHandle.dropDownVisible = false;
+      // }
+      // this.dataForm.parentId = !!value ? value : "";
     },
+    // 右侧列表的方法End
+    // areaHandleChange(value) {
+    //   if (value != "") {
+    //     this.dataForm.id =
+    //       this.dataForm.parentId.substring(0, 6) + value[value.length - 1];
+    //   } else {
+    //     this.dataForm.id = "";
+    //   }
+    // },
     handleAddType() {
       // 添加保险总公司
       this.operType = "ADD1";
       this.dialogTitle = "新增保险总公司";
       this.dataForm.parentId = "0";
       this.dialogVisible = true;
+      this.imgList1 = [];
+      this.uploadDisabled = false;
     },
     handleAddCompany(row) {
       console.log(row);
       this.operType = "ADD2";
       this.dialogTitle = "新增保险分公司";
       this.dataForm.parentId = row.id;
-      this.dataForm.logo = row.logo;
+      this.dataForm.logo = "";
+      this.dataForm.openQuote = row.openQuote;
       this.dialogVisible = true;
+      this.imgList1 = [];
+      this.uploadDisabled = false;
     },
     handleTableEdit(row) {
+      this.uploadDisabled = false;
       this.operType = "EDIT";
       this.dialogTitle = "编辑保险公司信息";
       this.dataForm.id = row.id;
@@ -511,18 +573,44 @@ export default {
       this.dataForm.remark = row.remark;
       this.dataForm.orderNum = row.orderNum;
       this.dataForm.cnName = row.cnName;
-      this.imgList1 = [];
-      this.imgList1.push({ url: row.logo });
+      this.dataForm.openQuote = 0;
+      // if (row.logo) {
+      //   this.imgList1 = [];
+      //   this.imgList1.push({ url: row.logo });
+      //   this.dataForm.logo = row.logo;
+      // } else {
+      //   this.imgList1 = [];
+      //   this.max = false;
+      // }
       if (row.openQuote == "1") {
         this.value = true;
       } else {
         this.value = false;
       }
       this.dialogVisible = true;
+      //查询详情
+      this.$api.insCompany.getInsCompanyById(this.dataForm.id).then((res) => {
+        this.dataForm.id = res.data.id;
+        this.dataForm.name = res.data.name;
+        this.dataForm.parentId = res.data.parentId;
+        this.dataForm.namesimple = res.data.namesimple;
+        this.dataForm.remark = res.data.remark;
+        this.dataForm.orderNum = res.data.orderNum;
+        this.dataForm.cnName = res.data.cnName;
+        this.dataForm.logo = res.data.logo;
+        if (res.data.logo == "") {
+          this.imgList1 = [];
+        } else {
+          this.imgList1 = [];
+          this.imgList1.push({ url: res.data.logo });
+          this.uploadDisabled = true;
+        }
+      });
     },
     handleTableDeleteFlag(data) {
-      console.log(111, data);
-      this.$api.insCompany.companyTree(data.params[0].id).then((res) => {
+      console.log("handleTableDeleteFlag", data);
+      this.uploadDisabled = false;
+      this.$api.insCompany.deleteEsmCompany(data.params[0].id).then((res) => {
         if (res.data.length > 0) {
           this.$message({
             message: "该公司下存在分公司,请先删除分公司",
@@ -537,130 +625,137 @@ export default {
         }
       });
     },
+    //删除操作
     handleTableBatchDelete(data) {
-      console.log(data.children.length);
-      let params = [];
-      let isFalg = true;
-      for (let i = 0; i < data.children.length; i++) {
-        this.$api.insCompany.companyTree(data.children[i].id).then((res) => {
-          console.log(res);
-          if (res.data.length > 0) {
-            isFalg = false;
-            this.$message({
-              message:
-                "公司(" +
-                res.data[0].id +
-                "-" +
-                res.data[0].name +
-                ")下存在分公司,请先删除分公司",
-              type: "info",
-            });
-          } else {
-            params.push(data.children[i].id);
-          }
-          if (i == data.children.length - 1 && isFalg) {
-            this.$api.insCompany
-              .deleteCompany(params)
-              .then(data != null ? data.callback : "");
-          }
-        });
-      }
-      //原来删除功能代码
-      // let params = [];
-      // let isFalg = true;
-      // for (let i = 0; i < data.params.length; i++) {
-      //   this.$api.insCompany.companyTree(data.params[i].id).then((res) => {
-      //     console.log(res, "====");
-      //     if (res.data.length > 0) {
-      //       isFalg = false;
-      //       this.$message({
-      //         message:
-      //           "公司(" +
-      //           res.data[0].id +
-      //           "-" +
-      //           res.data[0].name +
-      //           ")下存在分公司,请先删除分公司",
-      //         type: "info",
-      //       });
-      //     } else {
-      //       params.push(data.params[i].id);
-      //     }
-      //     if (i == data.params.length - 1 && isFalg) {
-      //       this.$api.insCompany
-      //         .deleteCompany(params)
-      //         .then(data != null ? data.callback : "");
-      //     }
-      //   });
-      // }
-    },
-
-    submitForm() {
-      if (this.operType == "ADD1") {
-        if (this.dataForm.id.length != 6) {
-          return this.$message({
-            message: "保险总公司的编码为6位",
+      let userName = Cookies.get("user");
+      if (userName === "admin") {
+        if (data.children.length > 0) {
+          this.$message({
+            message: "公司(" + data.name + ")下存在分公司,请先删除分公司",
             type: "info",
           });
         } else {
-          this.dataForm.id = this.dataForm.id.toUpperCase();
+          this.$api.insCompany.deleteEsmCompany(data.id).then((res) => {
+            if (res.code == 200) {
+              this.$message({
+                message: "删除成功",
+                type: "success",
+              });
+              this.findLeftTreeData();
+            } else this.$message.error("删除失败!");
+          });
         }
-      }
-      this.$refs.dataForm.validate((valid) => {
-        this.$api.insCompany.editCompany(this.dataForm).then((res) => {
-          if (res.code == 200) {
-            this.$message({ message: "操作成功", type: "success" });
-            this.findLeftTreeData();
-            this.dialogVisible = false;
-          }
+      } else {
+        this.$message({
+          message: "您还没有权限进行删除操作",
+          type: "info",
         });
+      }
+    },
+    //提交确认
+    submitForm(formName) {
+       this.$refs[formName].validate((valid) => {
         if (valid) {
-          this.$confirm("确认提交吗?", "提示", {})
-            .then(() => {
-              let params = {};
-              Object.assign(params, this.dataForm);
-              if (this.operType.indexOf("ADD") >= 0) {
-                this.$api.insCompany.addCompany(params).then((res) => {
-                  if (res.code == 200) {
-                    this.$message({ message: "操作成功", type: "success" });
-                    this.dialogVisible = false;
-                    this.findPage();
-                  } else {
-                    this.$message({ message: "操作失败", type: "error" });
-                  }
+          if (this.operType == "ADD1" || this.operType == "ADD2") {
+            if (this.operType == "ADD1") {
+              if (this.dataForm.id.length != 6) {
+                return this.$message({
+                  message: "保险总公司的编码为6位",
+                  type: "info",
                 });
               } else {
-                this.$api.insCompany
-                  .editCompany(params)
-                  .then((res) => {
-                    if (res.code == 200) {
-                      this.$message({ message: "操作成功", type: "success" });
-                      this.dialogVisible = false;
-                      this.findPage();
-                    } else {
-                      this.$message({ message: "操作失败", type: "error" });
-                    }
-                  })
-                  .catch(() => {
-                    this.$message({ message: "操作失败", type: "error" });
-                  });
+                this.dataForm.id = this.dataForm.id.toUpperCase();
               }
+            }
+            this.$refs.dataForm.validate((valid) => {
+              // console.log(this.dataForm);
+              // 新增保险总公司和分公司
+              this.$api.insCompany.addCompany(this.dataForm).then((res) => {
+                console.log(res);
+                if (res.code == 200) {
+                  this.findLeftTreeData();
+                  this.dialogVisible = false;
+                  this.$message({ message: "添加成功", type: "success" });
+                } else {
+                  this.$message({
+                    message: "编码重复,请重新输入",
+                    type: "info",
+                  });
+                }
+              });
+            });
+          } else {
+            this.dialogVisible = false;
+            //修改信息
+            this.$api.insCompany.editCompany(this.dataForm).then((res) => {
               this.findLeftTreeData();
-            })
-            .catch(() => {
-              this.$message({ type: "info", message: "已取消提交" });
+              this.$message({ message: "编辑成功", type: "success" });
             });
+          }
+        } else {
+          return false;
         }
       });
+
+
+      // this.$refs[formName].validate((valid) => {
+      //   if (valid) {
+      //     if (this.operType == "ADD1" || this.operType == "ADD2") {
+      //       if (this.operType == "ADD1") {
+      //         if (this.dataForm.id.length != 6) {
+      //           return this.$message({
+      //             message: "保险总公司的编码为6位",
+      //             type: "info",
+      //           });
+      //         } else {
+      //           this.dataForm.id = this.dataForm.id.toUpperCase();
+      //         }
+      //       }
+      //       this.$refs.dataForm.validate((valid) => {
+      //         // console.log(this.dataForm);
+      //         // 新增保险总公司和分公司
+      //         if(this.dialogTitle=="新增保险总公司"){
+      //           //调用当前接口
+      //         this.$api.insCompany.addCompany(this.dataForm).then((res) => {
+      //              if (res.code == 200) {
+      //             this.findLeftTreeData();
+      //             this.dialogVisible = false;
+      //               this.$message({ message: "添加成功", type: "success" });
+      //             } else {
+      //               this.$message({
+      //               message: "编码重复,请重新输入",
+      //               type: "info",
+      //               });
+      //            }
+      //         });
+      //       }else if(this.dialogTitle=="新增保险分公司"){
+      //             //调用另一个接口
+      //             //这个接口可以直接新增数据,后端不必判断编码
+
+      //           }
+      //       });
+      //     } else {
+      //       this.dialogVisible = false;
+      //       //修改信息
+      //       this.$api.insCompany.editCompany(this.dataForm).then((res) => {
+      //         this.findLeftTreeData();
+      //         this.$message({ message: "编辑成功", type: "success" });
+      //       });
+      //     }
+      //   } else {
+      //     return false;
+      //   }
+      // });
     },
 
     // 关闭新增对话框
-    handleClose(done) {
-      this.$confirm("确认关闭?")
-        .then((_) => {
-          done();
-        })
-        .catch((_) => {});
-    },
+    // handleClose(done) {
+    //   this.$confirm("确认关闭?", { lockScroll: false })
+    //     .then((_) => {
+    //       done();
+    //     })
+    //     .catch((_) => {});
+    // },
     closeVisible() {
       this.area = "";
       this.$refs.dataForm.resetFields();
@@ -693,11 +788,20 @@ export default {
       };
     },
     // 上传图片的方法End
+    //表格点击事件
+    handleRowClick(row) {
+      console.log(row);
+      row.expanded = !row.expanded;
+      this.$refs.expandTable.toggleRowExpansion(row, row.expanded);
+    },
   },
 };
 </script>
 
-<style>
+<style scoped>
+.disabled >>> .el-upload--picture-card {
+  display: none;
+}
 .avatar-uploader .el-upload {
   border: 1px dashed #d9d9d9;
   border-radius: 6px;