xjc 3 年之前
父節點
當前提交
6e1bdff684
共有 4 個文件被更改,包括 13869 次插入187 次删除
  1. 13642 0
      package-lock.json
  2. 1 2
      package.json
  3. 13 0
      src/api.js
  4. 213 185
      src/views/company/Grid.vue

文件差異過大導致無法顯示
+ 13642 - 0
package-lock.json


+ 1 - 2
package.json

@@ -20,7 +20,6 @@
     "vue-baidu-map": "^0.21.22",
     "vue-router": "^3.0.1",
     "vue-tree-color": "^2.3.2",
-    "vue2-org-tree": "^1.3.6",
     "vuex": "^3.0.1",
     "wangeditor": "^3.1.1"
   },
@@ -41,7 +40,7 @@
     "eslint-plugin-vue": "^5.0.0",
     "less": "^4.1.2",
     "less-loader": "^10.2.0",
-    "node-sass": "^4.11.0",
+    "node-sass": "^4.14.1",
     "sass-loader": "^7.1.0",
     "vue-cropper": "^0.4.9",
     "vue-template-compiler": "^2.5.21",

+ 13 - 0
src/api.js

@@ -226,4 +226,17 @@ export default {
 	getChartData: params => {
 		return axios.get(`${baseURL}/api/admin/dashboard/index`,{params:params})
 	},
+	// 网格化管理
+	addGridDetail: params => {
+		return axios.post(`${baseURL}/api/admin/grid/detail`, params);
+	},
+	getGridDetail: params => {
+		return axios.get(`${baseURL}/api/admin/grid/detail`, {params:params});
+	},
+	updateGridDetail: params => {
+		return axios.put(`${baseURL}/api/admin/grid/detail`, params);
+	},
+	getGridTree: params => {
+		return axios.get(`${baseURL}/api/admin/grid/tree`, {params:params});
+	},
 }

+ 213 - 185
src/views/company/Grid.vue

@@ -44,6 +44,7 @@
       .el-input--mini {
         width: 90%;
         margin-top: 10px;
+        padding-right: 5px;
       }
       .el-button--primary {
         width: 90%;
@@ -56,30 +57,30 @@
   margin-right: 10px;
 }
 // 企业端
-.qy_content{
-    background:#151932;
-    width:100%;
-    height:90vh;
-    margin-top:10px;
-    .grid-item{
-        padding:20px;
-        color: #fff;
-    }
-    .intro{
-        height: 90vh;
-        overflow-y: scroll;
-        line-height: 25px;
-    }
+.qy_content {
+  background: #151932;
+  width: 100%;
+  height: 90vh;
+  margin-top: 10px;
+  .grid-item {
+    padding: 20px;
+    color: #fff;
+  }
+  .intro {
+    height: 90vh;
+    overflow-y: scroll;
+    line-height: 25px;
+  }
 }
-.w-e-text-container{
+.w-e-text-container {
   height: 600px;
 }
-.bg-color-blue{
+.bg-color-blue {
   color: #fff;
-  background-color: #388CFF;
+  background-color: #388cff;
 }
-.org-tree-container{
-  background:none;
+.org-tree-container {
+  background: none;
 }
 </style>
 <template>
@@ -137,9 +138,9 @@
             </el-form>
             <div>
               <el-row :gutter="20">
-                <el-col :span="4">
-                  <div class="grid_item" v-for="item in gridList" :key="item.id">
-                    <div>
+                <el-col :span="4" v-for="item in gridList" :key="item.id">
+                  <div class="grid_item">
+                    <div style="position: relative">
                       <el-input
                         v-model="item.name"
                         placeholder="请输入"
@@ -149,52 +150,41 @@
                           slot="append"
                           icon="el-icon-edit"
                           size="mini"
-                          @click="dialogFormVisible1 = true"
+                          @click="editGridDetail(item)"
                         ></el-button>
                       </el-input>
+                      <i
+                        class="el-icon-arrow-right"
+                        style="
+                          position: absolute;
+                          top: 15px;
+                          right: 1px;
+                          cursor: pointer;
+                        "
+                      ></i>
                     </div>
                     <el-button type="primary" size="mini">添加</el-button>
                   </div>
                 </el-col>
-                <el-col :span="4">
-                  <div class="grid_item">1111</div>
-                </el-col>
-                <el-col :span="4">
-                  <div class="grid_item">1111</div>
-                </el-col>
-                <el-col :span="4">
-                  <div class="grid_item">1111</div>
-                </el-col>
-                <el-col :span="4">
-                  <div class="grid_item">1111</div>
-                </el-col>
               </el-row>
             </div>
           </li>
         </ul>
       </div>
       <el-dialog
-        title="编辑"
+        :title="'编辑' + curItem.name"
         :visible.sync="dialogFormVisible1"
-        width="800px"
+        width="1000px"
         :close-on-click-modal="false"
         :close-on-press-escape="false"
       >
         <el-form size="small" label-width="120px">
           <el-row :gutter="10">
-            <el-col :span="8">
-              <el-form-item label="类型">
-                <el-select clearable v-model="form1.utype" placeholder="请选择">
-                  <el-option label="部门级" value="部门级"></el-option>
-                  <el-option label="岗位级" value="岗位级"></el-option>
-                </el-select>
-              </el-form-item>
-            </el-col>
             <el-col :span="8">
               <el-form-item label="负责人姓名">
                 <el-input
                   v-model="form1.charge_person_name"
-                  placeholder=""
+                  placeholder="请输入负责人姓名"
                 ></el-input>
               </el-form-item>
             </el-col>
@@ -202,7 +192,15 @@
               <el-form-item label="负责人电话">
                 <el-input
                   v-model="form1.charge_person_phone"
-                  placeholder=""
+                  placeholder="请输入负责人手机号"
+                ></el-input>
+              </el-form-item>
+            </el-col>
+            <el-col :span="8">
+              <el-form-item label="车牌号">
+                <el-input
+                  v-model="form1.car_number"
+                  placeholder="仅配送相关职位填写"
                 ></el-input>
               </el-form-item>
             </el-col>
@@ -210,47 +208,47 @@
               <el-form-item label="负责人照片">
                 <div class="upload_div">
                   <i
-                    v-if="form.safecolor_img"
-                    @click="form.safecolor_img = ''"
+                    v-if="form1.charge_person_photo"
+                    @click="form1.charge_person_photo = ''"
                     class="el-icon-delete"
                   ></i>
                   <i class="el-icon-upload"></i>
                   <img
-                    v-if="form.safecolor_img"
+                    v-if="form1.charge_person_photo"
                     width="100%"
                     height="100%"
-                    :src="form.safecolor_img"
+                    :src="form1.charge_person_photo"
                     alt=""
                   />
                   <input
                     accept="image/png,image/jpg"
-                    @change="upload('safecolor_img')"
-                    id="safecolor_img"
+                    @change="upload('charge_person_photo')"
+                    id="charge_person_photo"
                     type="file"
                   />
                 </div>
               </el-form-item>
             </el-col>
             <el-col :span="8">
-              <el-form-item label="安全证书">
+              <el-form-item label="证件类型">
                 <div class="upload_div">
                   <i
-                    v-if="form.safecolor_img"
-                    @click="form.safecolor_img = ''"
+                    v-if="form1.certificate"
+                    @click="form1.certificate = ''"
                     class="el-icon-delete"
                   ></i>
                   <i class="el-icon-upload"></i>
                   <img
-                    v-if="form.safecolor_img"
+                    v-if="form1.certificate"
                     width="100%"
                     height="100%"
-                    :src="form.safecolor_img"
+                    :src="form1.certificate"
                     alt=""
                   />
                   <input
                     accept="image/png,image/jpg"
-                    @change="upload('safecolor_img')"
-                    id="safecolor_img"
+                    @change="upload('certificate')"
+                    id="certificate"
                     type="file"
                   />
                 </div>
@@ -278,7 +276,7 @@
           <el-button size="small" @click="dialogFormVisible1 = false"
             >取 消</el-button
           >
-          <el-button size="small" type="primary" @click="addStaff"
+          <el-button size="small" type="primary" @click="saveGridDetail"
             >确 定</el-button
           >
         </div>
@@ -286,7 +284,7 @@
       <el-dialog
         title="安全生产网格化管理简介"
         :visible.sync="dialogFormVisible2"
-        >
+      >
         <div>
           <fuEditor v-model="form.grid_security" :isClear="isClear"></fuEditor>
         </div>
@@ -298,28 +296,75 @@
     </div>
 
     <!-- 企业端 -->
-    <div class="qy_content">
-        <el-row :gutter="10">
+    <div class="qy_content" v-else>
+      <el-row :gutter="10">
+        <el-col :span="12">
+          <div
+            class="grid-item intro"
+            v-html="enterpriseInfo.grid_security"
+          ></div>
+        </el-col>
+        <el-col :span="12">
+          <div class="grid-item grid_chart">
+            <h2 align="center" style="margin-bottom: 10vh">
+              安全生产网格化管理责任图
+            </h2>
+            <vue2-org-tree
+              :data="treeData"
+              :label-class-name="labelClassName"
+              @on-node-click="nodeClick"
+            />
+          </div>
+        </el-col>
+      </el-row>
+      <el-dialog
+        title="详情"
+        :visible.sync="dialogFormVisible3"
+        width="600px"
+      >
+        <div>
+          <el-row :gutter="10">
             <el-col :span="12">
-                <div class="grid-item intro" v-html="enterpriseInfo.grid_security"></div>
+              <span>姓名:</span>
+              <span>{{form1.charge_person_name}}</span>
             </el-col>
             <el-col :span="12">
-                <div class="grid-item grid_chart">
-                    <h2 align="center" style="margin-bottom:10vh;">安全生产网格化管理责任图</h2>
-                    <vue2-org-tree :data="treeData" :label-class-name="labelClassName" />
-                </div>
+              <span>手机:</span>
+              <span>{{form1.charge_person_phone}}</span>
+            </el-col>
+            <el-col :span="12">
+              <span>照片:</span>
+              <img width="100px" :src="form1.charge_person_photo" alt="">
             </el-col>
-        </el-row>
+            <el-col :span="12">
+              <span>证件:</span>
+              <img width="100px" :src="form1.certificate" alt="">
+            </el-col>
+            <el-col :span="24">
+              <span>责任清单:</span>
+              <div>{{form1.duty_list}}</div>
+            </el-col>
+            <el-col :span="24">
+              <span>履职清单:</span>
+              <div>{{form1.job_list}}</div>
+            </el-col>
+          </el-row>
+        </div>
+        <div slot="footer">
+          <el-button @click="dialogFormVisible3 = false" size="mini">取 消</el-button>
+          <el-button type="primary" @click="dialogFormVisible3 = false" size="mini">确 定</el-button>
+        </div>
+      </el-dialog>
     </div>
   </section>
 </template>
 <script>
 import Page from "../../components/Page";
-import fuEditor from "@/components/fuEditor/index.vue"
+import fuEditor from "@/components/fuEditor/index.vue";
 export default {
   components: {
     Page,
-    fuEditor
+    fuEditor,
   },
   data() {
     return {
@@ -327,6 +372,7 @@ export default {
       dialogFormVisible: false,
       dialogFormVisible1: false,
       dialogFormVisible2: false,
+      dialogFormVisible3: false,
       data: [],
       form: { page: 1, page_size: 20 },
       list: [],
@@ -342,33 +388,10 @@ export default {
       staff: {},
       dptList: [],
       form1: {},
-      gridList: [
-        {
-          name: "公司负责人",
-          id: 1,
-          children: [
-            {
-              name: "安全科",
-              id: 2,
-              children: [
-                {
-                  name: "仓库运行班",
-                  id: 3,
-                  children: [
-                    {
-                      name: "储存员",
-                      id: 4,
-                      children: [],
-                    },
-                  ],
-                },
-              ],
-            },
-          ],
-        },
-      ],
-      utype: localStorage.getItem('utype',0),
-      treeData:{
+      gridList: [],
+      // utype: localStorage.getItem('utype',0),
+      utype: 2,
+      treeData1: {
         value: 0,
         label: "公司主要负责人",
         children: [
@@ -379,70 +402,77 @@ export default {
               {
                 value: 5,
                 label: "仓库运行班",
-                children:[
+                children: [
                   {
-                    value:7,
-                    label:"储存员"
+                    value: 7,
+                    label: "储存员",
                   },
                   {
-                    value:11,
-                    label:"搬运员"
+                    value: 11,
+                    label: "搬运员",
                   },
                   {
-                    value:12,
-                    label:"守护员"
-                  }
-                ]
+                    value: 12,
+                    label: "守护员",
+                  },
+                ],
               },
               {
                 value: 6,
                 label: "销售科",
-                children:[
+                children: [
                   {
-                    value:12,
-                    label:"甲销售员"
+                    value: 12,
+                    label: "甲销售员",
                   },
                   {
-                    value:12,
-                    label:"乙销售员"
-                  }
-                ]
+                    value: 12,
+                    label: "乙销售员",
+                  },
+                ],
               },
               {
                 value: 9,
                 label: "配送队",
-                children:[
+                children: [
                   {
-                    value:12,
-                    label:"甲配送员"
+                    value: 12,
+                    label: "甲配送员",
                   },
                   {
-                    value:12,
-                    label:"乙配送员"
-                  }
-                ]
-              }
-            ]
-          }
-        ]
+                    value: 12,
+                    label: "乙配送员",
+                  },
+                ],
+              },
+            ],
+          },
+        ],
       },
-      enterpriseInfo:{},
-      labelClassName:"bg-color-blue",
+      enterpriseInfo: {},
+      labelClassName: "bg-color-blue",
+      curItem: {},
+      treeData: {},
+      gridDetail:{}
     };
   },
   methods: {
-    getEnterpriseInfo(){
-      this.$api.getEnterprise({id:this.form.enterprise_id}).then(res=>{
+    getEnterpriseInfo() {
+      this.$api.getEnterprise({ id: this.form.enterprise_id }).then((res) => {
         this.dialogFormVisible2 = true;
         this.form.grid_security = res.data.data.grid_security;
         this.enterpriseInfo = res.data.data;
-      })
+      });
     },
-    updateEnterprise(){
-      let params = {id:this.form.enterprise_id,grid_security:this.form.grid_security,name:this.form.enterprise_name}
-      this.$api.updateEnterprise(params).then((res)=>{
+    updateEnterprise() {
+      let params = {
+        id: this.form.enterprise_id,
+        grid_security: this.form.grid_security,
+        name: this.form.enterprise_name,
+      };
+      this.$api.updateEnterprise(params).then((res) => {
         this.dialogFormVisible2 = false;
-      })
+      });
     },
     gopage(size) {
       if (size) {
@@ -460,17 +490,20 @@ export default {
       });
       this.form.enterprise_id = data.id;
       this.form.enterprise_name = data.name;
-      this.$api.getEnterprise({id:this.form.enterprise_id}).then(res=>{
+      this.$api.getEnterprise({ id: this.form.enterprise_id }).then((res) => {
         this.form.grid_security = res.data.data.grid_security;
         this.enterpriseInfo = res.data.data;
-      })
+      });
+      // 机构树
+      this.$api.getGridTree({ enterprise_id: this.id }).then((res) => {
+        this.treeData = res.data.data;
+        this.gridList = res.data.data;
+      });
     },
     getData() {
       this.loading = true;
       this.$api.getEnterpriseList({ name: this.name }).then((res) => {
         this.data = res.data.data.list;
-        // this.id=this.data[0].id;
-        // this.enterprise_name=this.data[0].name;
         this.change(this.data[0]);
       });
     },
@@ -497,58 +530,22 @@ export default {
         });
       });
     },
-    addStaff() {
-      let parm = this.staff;
-
-      if (!parm.name) {
-        this.$message.error("请输入员工名称");
-        return;
-      }
-      if (!parm.username) {
-        this.$message.error("请输入账号");
-        return;
-      }
-      if (!parm.password) {
-        this.$message.error("请输入密码");
-        return;
-      }
-      if (!parm.utype) {
-        this.$message.error("请选择账号类型");
-        return;
-      }
-      if (parm.utype != "公司级" && !parm.department_id) {
-        this.$message.error("请选择部门");
-        return;
-      }
-      if (parm.id) {
-        this.$api.updateStaffuser(parm).then((res) => {
-          if (res.data.code == 0) {
-            this.getDpt();
-            this.staff = {};
-            this.$message({
-              message: "修改成功",
-              type: "success",
-            });
-            this.dialogFormVisible1 = false;
-          } else {
+    saveGridDetail() {
+      let params = this.form1;
+      params.enterprise_grid_id = this.curItem.id;
+      if (params.id) {
+        this.$api.updateGridDetail(params).then((res) => {
+          if (res.data.code != 0) {
             this.$message.error(res.data.message);
           }
+          this.dialogFormVisible1 = false;
         });
       } else {
-        parm.id = 0;
-        parm.enterprise_id = this.id;
-        this.$api.saveStaffuser(parm).then((res) => {
-          if (res.data.code == 0) {
-            this.getDpt();
-            this.staff = {};
-            this.$message({
-              message: "新增成功",
-              type: "success",
-            });
-            this.dialogFormVisible1 = false;
-          } else {
+        this.$api.addGridDetail(params).then((res) => {
+          if (res.data.code != 0) {
             this.$message.error(res.data.message);
           }
+          this.dialogFormVisible1 = false;
         });
       }
     },
@@ -559,6 +556,37 @@ export default {
       this.dialogFormVisible1 = true;
       this.staff = { ...data };
     },
+    editGridDetail(item) {
+      if (!item.name) {
+        this.$message.error("请先填写名称再编辑!");
+        return;
+      }
+      this.dialogFormVisible1 = true;
+      this.curItem = item;
+      this.$api.getGridDetail({ id: item.id }).then((res) => {
+        this.form1 = res.data.data;
+      });
+    },
+    upload(type) {
+      var file = document.getElementById(type).files;
+      var data = new FormData();
+      data.append("file", file[0]);
+      this.$api.uploadFile(data).then((res) => {
+        if (res.data.code == 0) {
+          let form = this.form1;
+          this.$set(form, type, res.data.data.url);
+          this.$message({ message: "上传成功!", type: "success" });
+        } else {
+          this.$message.error(res.data.message);
+        }
+      });
+    },
+    nodeClick(e,data){
+      this.$api.getGridDetail({ id: data.value }).then((res) => {
+        this.form1 = res.data.data;
+        this.dialogFormVisible3 = true;
+      });
+    }
   },
   created() {
     this.getData();