wenbobowen 4 years ago
parent
commit
f400118679

+ 2 - 2
src/api/publishTask.js

@@ -22,7 +22,7 @@ export function getBizBindTemList(data) {
 
 export function getOnlineBizModule(data) {
   return request({
-    url: `${host}/checklist/selectBizModule?taskId=${data.taskId}&query=${data.query}`,
+    url: `${host}/checklist/selectBizModule?taskId=${data.taskId}&moduleName=${data.moduleName}`,
     method: 'get',
     data
   })
@@ -30,7 +30,7 @@ export function getOnlineBizModule(data) {
 
 export function updateChecklist(data) {
   return request({
-    url: `${host}/checklist/updateTemplateCheckStatus`,
+    url: `${host}/checklist/update`,
     method: 'post',
     data
   })

+ 3 - 2
src/views/projectManage/publishTask/components/checkboxList.vue

@@ -1,5 +1,5 @@
 <template>
-  <el-checkbox-group v-model="selectedList" @change="$emit('change', selectedList)">
+  <el-checkbox-group v-model="List" @change="$emit('change', List)">
     <el-checkbox v-for="item in data" :key="item.id" class="checkbox" :label="item.id">{{ item.name }}</el-checkbox>
   </el-checkbox-group>
 </template>
@@ -23,7 +23,8 @@ export default {
       checkAll: false,
       // checkedCities: ['上海', '北京'],
       // cities: cityOptions,
-      isIndeterminate: true
+      isIndeterminate: true,
+      List: this.selectedList
     }
   },
   methods: {

+ 18 - 18
src/views/projectManage/publishTask/components/onlineCheckList.vue

@@ -23,7 +23,7 @@
               placeholder="请选择模块"
               :remote-method="remoteMethod"
               :loading="loading"
-              @change="clearHandle(d.module)"
+              @change="clearHandle(index)"
             >
               <el-option
                 v-for="item in options"
@@ -32,7 +32,7 @@
                 :value="item"
               />
             </el-select>
-            <span class="addBtn" @click="addModule(d.module)">添加</span>
+            <span class="addBtn" @click="addModule(index)">添加</span>
           </div>
           <div v-if="isedit">
             <el-tag
@@ -42,7 +42,7 @@
               size="small"
               closable
               type="info"
-              @close="handleClose(d.module, tag)"
+              @close="handleClose(index, tag)"
             >
               {{ tag }}
             </el-tag>
@@ -119,7 +119,7 @@ export default {
     moduleId: {
       type: Number,
       required: true,
-      default: null
+      default: -1
     },
     taskId: {
       type: Number,
@@ -134,7 +134,7 @@ export default {
       value: [],
       loading: false,
       size: 'small',
-      query: '',
+      moduleName: '',
       name: ''
     }
   },
@@ -142,26 +142,26 @@ export default {
     console.log(1111111111)
   },
   methods: {
-    async remoteMethod(query) {
-      this.query = query
-      if (query !== '') {
+    async remoteMethod(moduleName) {
+      this.moduleName = moduleName
+      if (moduleName !== '') {
         this.loading = true
-        const res = await getOnlineBizModule({ taskId: this.taskId, query })
+        const res = await getOnlineBizModule({ taskId: this.taskId, moduleName })
         this.options = res.data
         this.loading = false
       } else {
         this.options = []
       }
     },
-    clearHandle(m) {
-      console.log(m, this.value)
-      this.$emit('changeSelectedHandle', this.moduleId, m, this.value[0], 'add')
-      this.query = ''
+    clearHandle(subIdx) {
+      console.log(subIdx, this.value)
+      this.$emit('changeSelectedHandle', this.moduleId, subIdx, this.value[0], 'add')
+      this.moduleName = ''
       this.value = null
     },
-    addModule(m) {
-      if (this.query) {
-        this.$emit('changeSelectedHandle', this.moduleId, m, this.query, 'add')
+    addModule(subIdx) {
+      if (this.moduleName) {
+        this.$emit('changeSelectedHandle', this.moduleId, subIdx, this.moduleName, 'add')
       }
     },
     getfocus(index) {
@@ -169,8 +169,8 @@ export default {
       // window.elemmm[`s${index}`]=this.$refs[`s${index}`]
       // this.$refs[`s${index}`][0].focused()
     },
-    handleClose(m, val) {
-      this.$emit('changeSelectedHandle', this.moduleId, m, val, 'del')
+    handleClose(subIdx, val) {
+      this.$emit('changeSelectedHandle', this.moduleId, subIdx, val, 'del')
     },
     // 开始拖拽事件
     onStart() {

+ 50 - 19
src/views/projectManage/publishTask/index.vue

@@ -23,14 +23,14 @@
         </div>
         <div class="moduleList wrap">
           <redTipword v-if="!edit" title="检查项" :isedit="edit" />
-          <div v-for="(item, index) in data.templates" :key="item.id" class="item">
+          <div v-for="(item, index) in data.templates" :key="item.parentTemplateId" class="item">
             <div v-if="item.type === 1">
-              <p :id="`s${item.id}`" class="title">
-                <el-checkbox v-if="!edit" v-model="item.isCheck" :label="item.name" @change="updateCheckItemHandle(item.isCheck, item)">{{ item.name }}</el-checkbox>
+              <p :id="`s${item.parentTemplateId}`" class="title">
+                <el-checkbox v-if="!edit" v-model="item.isCheck" :label="item.name" @change="updateCheckItemHandle(item)">{{ item.name }}</el-checkbox>
                 <span v-else>{{ item.name }}</span>
               </p>
               <onlineCheckList
-                :module-id="item.id"
+                :module-id="item.parentTemplateId"
                 :isedit="edit"
                 :data="item.onlineModule"
                 :task-id="taskId"
@@ -40,13 +40,13 @@
               />
             </div>
             <div v-else>
-              <p :id="`s${item.id}`" class="title">
+              <p :id="`s${item.parentTemplateId}`" class="title">
                 <el-checkbox v-if="!edit" v-model="item.isCheck" :label="item.name" @change="updateCheckItemHandle(item)">{{ item.name }}</el-checkbox>
                 <span v-else>{{ item.name }}</span>
               </p>
               <normal-area
                 v-if="edit"
-                :id="'tem'+item.id"
+                :id="'tem'+item.parentTemplateId"
                 :value.sync="item.content"
                 :empty-text="'点击'"
                 :input-button="'修改模板'"
@@ -159,7 +159,6 @@ export default {
   methods: {
     // 获取checklist详情
     async getList() {
-      console.log(this.taskId)
       if (this.taskId) {
         const res = await getCheckListBytask({ taskId: this.taskId })
         // res.data = null
@@ -175,6 +174,7 @@ export default {
 
     // 获取业务线下绑定的可以选checklist列表
     async getBizBindTemList() {
+      console.log(1111)
       const { bizId = null } = store.state.global || {}
       const res = await getBizBindTemList({ name: '', bizId })
       this.temList = res.data
@@ -217,7 +217,7 @@ export default {
     },
 
     // 添加或者删除线上模板的模版名
-    changeOnlineSelectedHandle(id, name, value, type) {
+    changeOnlineSelectedHandle(id, subIdx, value, type) {
       /**
        * id: 模块id
        * name: 线上模块中哪个模块下的模块名称
@@ -225,24 +225,28 @@ export default {
        * type: 是添加还是删除
       **/
       // const tem = this.data.templates
+      console.log(this.data, id, subIdx, value, type)
       this.data.templates.map(t => {
-        if (t.id === id) {
+        if (t.parentTemplateId === id) {
           if (type === 'del') {
             t.onlineModule.onlineOrder = t.onlineModule.onlineOrder.filter(g => g !== value)
-            t.onlineModule.tableContent.map(t => {
-              if (t.module === name) {
+            t.onlineModule.tableContent.map((t, i) => {
+              if (i === subIdx) {
                 t.moduleNames = t.moduleNames.filter(g => g !== value)
               }
             })
           } else if (!t.onlineModule.onlineOrder.includes(value)) {
             t.onlineModule.onlineOrder.push(value)
-            t.onlineModule.tableContent.map(t => {
-              if (t.module === name) {
+            t.onlineModule.tableContent.map((t, i) => {
+              if (i === subIdx) {
                 t.moduleNames.push(value)
               }
             })
           } else {
-            console.log('已经添加过该模块名称')
+            this.$message({
+              message: '已经添加过该模块名称',
+              type: 'error'
+            })
           }
         }
       })
@@ -251,11 +255,19 @@ export default {
     changeOnlineModuleRow(type, mId, index) {
       console.log(type, mId, index, this.data.templates)
       this.data.templates.map(t => {
-        if (t.id === mId) {
+        if (t.parentTemplateId === mId) {
           if (type === 'del') {
+            console.log(t.onlineModule)
+            const delModuleNames = t.onlineModule.tableContent[index].moduleNames
+            const test = t.onlineModule.onlineOrder.filter(t => !delModuleNames.includes(t))
+            console.log(delModuleNames, test)
+            t.onlineModule.onlineOrder = t.onlineModule.onlineOrder.filter(t => !delModuleNames.includes(t))
             t.onlineModule.tableContent.splice(index, 1)
           } else {
-            t.onlineModule.tableContent.splice(index + 1, 0, {})
+            t.onlineModule.tableContent.splice(index + 1, 0, {
+              module: `模块${index + 1}`,
+              moduleNames: []
+            })
           }
         }
       })
@@ -343,7 +355,16 @@ export default {
       if (!selectedBizTemplateIds || selectedBizTemplateIds.length < 1) {
         this.temList.map(t => {
           this.data.selectedBizTemplateIds.push(t.id)
-          this.data.templates.push(t)
+          const { content, isCheck, name, onlineModule, type, id: parentTemplateId } = t
+          this.data.templates.push({
+            content,
+            isCheck,
+            name,
+            onlineModule,
+            type,
+            parentTemplateId,
+            belongType: 2 // checklist的模板
+          })
         })
       }
     },
@@ -370,7 +391,16 @@ export default {
         this.temList.map(t => {
           if (t.id === checkedId) {
             selectedBizTemplateIds.push(t.id)
-            templates.push(t)
+            const { content, isCheck, name, onlineModule, type, id: parentTemplateId } = t
+            templates.push({
+              content,
+              isCheck,
+              name,
+              onlineModule,
+              type,
+              parentTemplateId,
+              belongType: 2 // checklist的模板
+            })
           }
         })
       })
@@ -408,8 +438,9 @@ export default {
     async updateCheckItemHandle(item) {
       console.log(item)
       const { id: templateId, isCheck } = item
-      const res = await updateTemplateCheckStatus({ templateId, isCheck })
+      const res = await updateTemplateCheckStatus({ templateId, isCheck, taskId: this.taskId })
       if (res.code === 200) {
+        this.getRecordList()
         this.$message({
           message: '检查项状态更新成功',
           type: 'success'

+ 6 - 1
src/views/projectManage/taskList/taskViewDetail.vue

@@ -326,6 +326,7 @@
       <el-container v-if="activeName === '6'" class="is-vertical">
         <!-- <section class="main-section contain"> -->
         <publishTask
+          v-if="loaded"
           :task-id="form_query.id"
           :task-name="form_query.name"
           :user-names="userNames"
@@ -538,7 +539,8 @@ export default {
       synchronizeDialog: false, // 同步任务至望月弹框
       dplOption: [], // 关联的望岳任务
       checklistStopVisible: false, // checklist拦截弹窗是否显示
-      firstChecklistTaskId: -1
+      firstChecklistTaskId: -1,
+      loaded: false // 是否请求到当前任务的task信息
     }
   },
 
@@ -709,6 +711,9 @@ export default {
       const res = await taskGet(this.taskId)
       if (res.code === 200) {
         this.form_query = res.data
+        if (!this.loaded) {
+          this.loaded = true
+        }
         if (this.form_query.isDirectlyFromDpm === 0 || this.form_query.isDirectlyFromDpm === 1) {
           this.toilp = this.form_query.relatedDpmTaskInfo.taskId + this.form_query.relatedDpmTaskInfo.name
         }