Просмотр исходного кода

团队信息tab增加【添加/设为负责人/删除】功能

NULL1222 4 часов назад
Родитель
Сommit
d84fb66a88

+ 72 - 89
src/bgj/workOrderManage/modules/addTeam.vue

@@ -8,127 +8,110 @@
       :title="$t(`添加团队人员`)"
       :visible.sync="dialogFormVisible"
       width="900px"
+      top="3vh"
+      @open="getList"
     >
       <el-input
-        style="width: 200px"
+        style="width: 200px; margin-bottom: 15px"
         :placeholder="$t('搜索')"
-        :suffix-icon="
-          condition ? (condition.length > 0 ? '' : '') : 'el-icon-search'
-        "
+        suffix-icon="el-icon-search"
         v-model="condition"
-        @keyup.native.enter="getLeaderList()"
-        @clear="getLeaderList"
+        @keyup.native.enter="getList()"
+        @clear="getList"
         size="small"
-        class="input-with-select inline-16 layout_search__panel"
         clearable
+      />
+      <el-table
+        ref="table"
+        :data="teamList"
+        stripe
+        border
+        size="small"
+        :height="tableHeight"
+        style="width: 100%"
+        @selection-change="selectChange"
       >
-      </el-input>
+        <el-table-column type="selection" width="45" align="center" />
+        <el-table-column prop="name" :label="$t('姓名')" min-width="150" show-overflow-tooltip />
+        <el-table-column prop="position" :label="$t('职位')" min-width="150" show-overflow-tooltip />
+        <el-table-column prop="phonenumber" :label="$t('手机号')" min-width="180" show-overflow-tooltip />
+      </el-table>
+      <span slot="footer">
+        <el-button @click="dialogFormVisible = false" size="small">{{
+          $t(`取 消`)
+        }}</el-button>
+        <el-button
+          type="primary"
+          @click="onSubmit"
+          size="small"
+          :loading="submitLoading"
+          :disabled="selectArr.length <= 0"
+          >{{ $t(`确 定`) }}</el-button
+        >
+      </span>
     </el-dialog>
   </div>
 </template>
 
 <script>
-import selectTable from "@/components/selectTable/index";
 export default {
   props: ["data"],
-  components: { selectTable },
   data() {
     return {
       dialogFormVisible: false,
-      classList: [],
-      disabledId: [],
-      tableList: [],
-      tablecols: [],
-      result: [],
+      teamList: [],
       condition: "",
-      leaderList: [],
+      selectArr: [],
+      submitLoading: false,
+      tableHeight: "calc(75vh - 200px)",
     };
   },
   methods: {
-    // async onSubmit(data) {
-    //     let res = await this.$api.requested({
-    //         id: 20220927090106,
-    //         content: {
-    //             itemtype: 1, //1=总部 2=本地
-    //             itemclassids: [data.itemclassid],
-    //             itemid: this.data.data.sc_itemid,
-    //             itemno: this.data.data.code,
-    //         },
-    //     });
-    //     this.tool.showMessage(res, () => {
-    //         this.$emit("onSuccess");
-    //         this.getClassList();
-    //     });
-    // },
-    async getLeaderList() {
-      let res = await this.$api.requested({
-        id: 2026052109150402,
+    async getList() {
+      const res = await this.$api.requested({
+        id: 2026061111062302,
         content: {
-          pageNumber: 1,
-          pageSize: 100,
+          sc_workorderid: this.$route.query.id,
           where: {
-            condition: "",
+            condition: this.condition,
           },
         },
       });
-      this.leaderList = res.data;
-      console.log("this.leaderList", this.leaderList);
+      this.teamList = res.data || [];
+    },
+    selectChange(data) {
+      this.selectArr = data;
+    },
+    async onSubmit() {
+      if (this.selectArr.length <= 0) return;
+      this.submitLoading = true;
+      const res = await this.$api.requested({
+        id: 2026061111040702,
+        content: {
+          sc_workorderid: this.$route.query.id,
+          userids: this.selectArr.map((item) => item.userid),
+        },
+      });
+      this.submitLoading = false;
+      if (res.code === 0) {
+        this.$message.error(res.data[0].errmsg);
+      } else {
+        this.$message({
+          message: this.$t("添加成功"),
+          type: "success",
+        });
+        this.dialogFormVisible = false;
+        this.selectArr = [];
+        this.$emit("onSuccess");
+      }
     },
-    // async getClassList() {
-    //     let res = await this.$api.requested({
-    //         id: "20230325141103",
-    //         content: {
-    //             sa_brandid: 0,
-    //             itemid: this.$route.query.id,
-    //             where: {
-    //                 istool: this.data.data.istool ? 1 : 0,
-    //                 condition: this.condition,
-    //             },
-    //         },
-    //     });
-    //     console.log(res.data);
-    //     res.data = res.data.map((item, index) => {
-    //         return {
-    //             itemclassname: item.brandname,
-    //             itemclassid: index + 1,
-    //             subdep: item.ttemclass,
-    //         };
-    //     });
-    //     this.classList = this.createDeep(res.data);
-    //     console.log(this.classList);
-    // },
-    // createDeep(data) {
-    //     let arr = [];
-    //     function createNodes(node, first) {
-    //         let elNode = {
-    //             itemclassname: node.itemclassfullname
-    //                 ? node.itemclassfullname
-    //                 : node.itemclassname,
-    //             itemclassid: node.itemclassid,
-    //             itemclassnum: node.itemclassnum,
-    //             children: [],
-    //             disabled: first ? false : true,
-    //         };
-    //         if (node.subdep && node.subdep.length > 0) {
-    //             for (let index = 0; index < node.subdep.length; index++) {
-    //                 elNode.children.push(createNodes(node.subdep[index]));
-    //             }
-    //         }
-    //         return elNode;
-    //     }
-
-    //     data.forEach((item) => {
-    //         this.disabledId.push(item.itemclassid);
-    //         arr.push(createNodes(item, true));
-    //     });
-    //     return arr;
-    // },
   },
   created() {
-    this.getLeaderList();
+    this.getList();
   },
 };
 </script>
+
 <style scoped>
 /deep/.el-dialog__body {
   padding-bottom: 0 !important;

+ 3 - 6
src/bgj/workOrderManage/modules/detail.vue

@@ -72,15 +72,12 @@
         <material :data="mainData"></material>
       </div>
       <div slot="slot3">
-        <team :data="mainData">
+        <team ref="team" :data="mainData" @onSuccess="queryMainData($route.query.id)">
           <template v-slot:addTeam="scope">
-            <!-- v-if="(mainData.status === '待开始'||mainData.status === '进行中'||mainData.status === '暂停')&& tool.checkAuth($route.name, 'editTeam')" -->
             <addTeam
+              v-if="(mainData.status === '待开始'||mainData.status === '进行中'||mainData.status === '暂停')&& tool.checkAuth($route.name, 'editTeam')" 
               :data="scope.data"
-              @onSuccess="
-                $refs.saleClass.listData();
-                queryMainData($route.query.id);
-              "
+              @onSuccess="$refs.team.listData()"
             />
           </template>
         </team>

+ 41 - 18
src/bgj/workOrderManage/modules/team.vue

@@ -60,16 +60,25 @@
             scope.row.position || "--"
           }}</template>
         </el-table-column>
-        <el-table-column :label="$t('操作')" width="160">
+        <el-table-column
+          :label="$t('操作')"
+          width="160"
+          v-if="
+            (data.status === '待开始' ||
+              data.status === '进行中' ||
+              data.status === '暂停') &&
+            tool.checkAuth($route.name, 'editTeam')
+          "
+        >
           <template slot-scope="scope">
             <el-button
               type="text"
               size="mini"
-              @click="onLeader(scope)"
+              @click="onLeader(scope.row)"
               v-if="!scope.row.isLeader"
               >{{ $t("设为负责人") }}</el-button
             >
-            <el-button type="text" size="mini" @click="onDelete(scope)">{{
+            <el-button type="text" size="mini" @click="onDelete(scope.row)">{{
               $t("删除")
             }}</el-button>
           </template>
@@ -114,6 +123,7 @@ export default {
         },
       },
       options: [],
+      deleteLoading: false,
     };
   },
   methods: {
@@ -129,26 +139,35 @@ export default {
       }
     },
     buildTableData(list) {
-      const result = [];
+      const leaders = [];
+      const members = [];
+
       list.forEach((group) => {
-        const leader = (group.teamleader && group.teamleader[0]) || {};
-        const members = group.team || [];
-        result.push({
-          name: leader.name || group.teamname || "--",
-          phonenumber: leader.phonenumber || "--",
-          position: leader.position || "--",
-          isLeader: true,
-        });
-        members.forEach((member) => {
-          result.push({
+        const leaderArr = group.teamleader || [];
+        const leader = leaderArr[0];
+        const groupMembers = group.team || [];
+        if (leader) {
+          leaders.push({
+            name: leader.name || group.teamname || "--",
+            phonenumber: leader.phonenumber || "--",
+            position: leader.position || "--",
+            isLeader: true,
+            userid: leader.userid || "",
+          });
+        }
+        groupMembers.forEach((member) => {
+          members.push({
             name: member.name || "--",
             phonenumber: member.phonenumber || "--",
             position: member.position || "--",
             isLeader: false,
+            userid: member.userid || "",
           });
         });
       });
-      this.tableData = result;
+
+      // 负责人全部在前,成员全部在后
+      this.tableData = [...leaders, ...members];
     },
     handleSizeChange(val) {
       // console.log(`每页 ${val} 条`);
@@ -170,9 +189,11 @@ export default {
       console.log("data", data);
       this.$confirm(
         this.$t("是否确定将") +
+          " " +
           data.name +
           "_" +
           data.position +
+          " " +
           this.$t("设为当前工单的负责人") +
           "?",
         this.$t("提示"),
@@ -199,7 +220,8 @@ export default {
               message: this.$t("操作成功"),
               type: "success",
             });
-            this.$store.dispatch("changeDetailDrawer", false);
+            this.listData();
+            this.$emit("onSuccess");
           }
         })
         .catch(() => {
@@ -212,7 +234,7 @@ export default {
     onDelete(data) {
       console.log("data", data);
       this.$confirm(
-        this.$t("是否确定删除") + data.name + "_" + data.position + "?",
+        this.$t("是否确定删除") + " " + data.name + "_" + data.position + "?",
         this.$t("提示"),
         {
           confirmButtonText: this.$t("确定"),
@@ -237,7 +259,8 @@ export default {
               message: this.$t("删除成功"),
               type: "success",
             });
-            this.$store.dispatch("changeDetailDrawer", false);
+            this.listData();
+            this.$emit("onSuccess");
           }
         })
         .catch(() => {