qinzhipeng_v@didiglobal.com 4 жил өмнө
parent
commit
66923fd829

+ 30 - 6
src/views/reportManagement/ReleaseReport/newReleaeTemplate.vue

@@ -97,9 +97,9 @@
           <search-people :value.sync="from.tester" :clearable="true" :multiple="true" :size="'small'" :disabled="releaseType" style="width: 100%;" />
         </el-col>
       </el-row>
-
+      {{ customList }}
       <!-- 自定义反显组件 -->
-      <moduleCustom v-if="customList && customList[0]" :custom="customList" :disab="releaseType" @formData="formData" />
+      <moduleCustom v-if="customList && customList[0]" :custom="customList" :base-from="from" :disab="releaseType" @formData="formData" />
 
       <normal-area
         id="report-template-1"
@@ -222,7 +222,8 @@ export default {
     setDefaultData(dav) {
       const from = dav
       this.from = { ...this.from, ...dav, 'taskIds': from.taskId }
-      // this.customList = from.customFields
+      this.customList = from.customFields
+      console.log(dav, '编辑')
       if (from.devPlanTimeStart) {
         this.$set(this.from, 'devPlanTimeStart', [from.devPlanTimeStart, from.devPlanTimeEnd]) // 计划开发开始时间-计划开发结束时间
       }
@@ -295,6 +296,19 @@ export default {
 
     // 创建准出报告
     reportreleaseCreate(val) {
+      let show = '0'
+      this.from.customFields.map(item => {
+        if (item.bool && item.required && item.type < 4) {
+          item.type < 4 && item.content ? '' : show = item.fieldName
+        }
+        if (item.bool && item.required && item.type === 4) {
+          item.contents ? '' : show = item.fieldName
+        }
+      })
+      if (show !== '0') {
+        this.$message({ type: 'warning', message: `${show}不能为空` })
+        return
+      }
       this.$refs.fromCreateData.validate(async(valid) => {
         if (valid) {
           this.loading = true
@@ -396,9 +410,19 @@ export default {
       })
     },
 
-    formData(val) { // 编辑自定义字段获取content
-      this.from = { ...this.from, customFields: val }
-      console.log(this.from, val, 'cdcsdcs')
+    formData({ customs, keys, params }) { // 编辑自定义字段获取content
+      const newFrom = { ...this.from, customFields: customs }
+      newFrom.customFields.forEach(elm => {
+        if (keys.indexOf(elm.conditions) > -1) {
+          elm.content = ''
+          elm.contents = []
+        }
+      })
+      keys.forEach(key => {
+        delete newFrom[key]
+      })
+      this.from = { ...newFrom, ...params }
+      console.log(customs, params, 'customs')
     },
 
     customDialong() { // 点击自定义字段

+ 22 - 7
src/views/reportManagement/Testing/newTestingTemplate.vue

@@ -73,7 +73,7 @@
         <el-col :span="12" class="Layout_flex_start">
           <span class="from-name">是否跟版: </span>
           <template>
-            <el-radio-group v-model="from.followVersion" :disabled="releaseType">
+            <el-radio-group v-model="from.followVersion" :disabled="releaseType" @change="setFrom({ 'followVersion': from.followVersion })">
               <el-radio :label="2">否</el-radio>
               <el-radio :label="1">是</el-radio>
             </el-radio-group>
@@ -91,7 +91,7 @@
         <el-col :span="12" class="Layout_flex_start">
           <span class="from-name"><span style="color: red;">*</span>CodeReview:</span>
           <template>
-            <el-radio-group v-model="from.isCodeReview" :disabled="releaseType">
+            <el-radio-group v-model="from.isCodeReview" :disabled="releaseType" @change="setFrom({ 'isCodeReview': from.isCodeReview })">
               <el-radio :label="0">否</el-radio>
               <el-radio :label="1">是</el-radio>
             </el-radio-group>
@@ -104,7 +104,8 @@
       </el-row>
 
       <!-- 自定义反显组件 -->
-      <moduleCustom v-if="customList && customList[0]" :custom="customList" :disab="releaseType" @formData="formData" />
+      <!-- <moduleCustom v-if="customList && customList[0]" ref="moduleCustom" :custom="customList" :disab="releaseType" @formData="formData" /> -->
+      <moduleCustom v-if="customList && customList[0]" ref="moduleCustom" :custom="customList" :base-from="from" :disab="releaseType" @formData="formData" />
 
     </el-form>
 
@@ -239,6 +240,11 @@ export default {
       }
     },
 
+    setFrom(e) {
+      console.log(e)
+      this.$refs.moduleCustom.CustomSet(e)
+    },
+
     async reportdelivertestInitReportRelease(val) { // 报告时间
       const res = await reportdelivertestInitReportRelease({ taskIds: val })
       if (res.code === 200) {
@@ -330,11 +336,20 @@ export default {
       this.$router.push({ name: '需求详情', query: { bizId_id: bizId_id }})
     },
 
-    formData(val) { // 编辑自定义字段获取content
-      this.from = { ...this.from, customFields: val }
-      console.log(val, 'cdcsdcs')
+    formData({ customs, keys, params }) { // 编辑自定义字段获取content
+      const newFrom = { ...this.from, customFields: customs }
+      newFrom.customFields.forEach(elm => {
+        if (keys.indexOf(elm.conditions) > -1) {
+          elm.content = ''
+          elm.contents = []
+        }
+      })
+      keys.forEach(key => {
+        delete newFrom[key]
+      })
+      this.from = { ...newFrom, ...params }
+      console.log(customs, params, 'customs')
     },
-
     customDialong() { // 点击自定义字段
       console.log(this.customList, this.from, '模版组件返回')
       this.$emit('setCustom', this.customList, this.from)

+ 13 - 9
src/views/reportManagement/components/Custom/index.vue

@@ -59,7 +59,8 @@
 <script>
 export default {
   props: {
-    custom: { type: Array, default: null }
+    custom: { type: Array, default: null },
+    reporttype: { type: String, required: false, default: null }
   },
   data() {
     return {
@@ -84,19 +85,22 @@ export default {
         { value: true, label: '必填' }
       ],
       options: [
-        { value: '默认展示', label: '默认展示' },
-        { value: '是否跟版 - 是', label: '是否跟版 - 是' },
-        { value: '是否跟版 - 否', label: '是否跟版 - 否' },
-        { value: '是否codereview - 是', label: '是否codereview - 是' },
-        { value: '是否codereview - 否', label: '是否codereview - 否' }
+        { value: '默认展示', label: '默认展示' }
+      ],
+      types: [
+        { value: '是否跟版_1', label: '是否跟版 - 是' },
+        { value: '是否跟版_2', label: '是否跟版 - 否' },
+        { value: '是否codereview_1', label: '是否codereview - 是' },
+        { value: '是否codereview_0', label: '是否codereview - 否' }
       ]
     }
   },
   watch: {
-    custom: {
+    reporttype: {
       handler(newV) {
-        console.log(newV)
-        // this.setAddCustomContent(newV)
+        if (newV) {
+          this.options = [...this.options, ...this.types]
+        }
       },
       immediate: true
     }

+ 1 - 1
src/views/reportManagement/components/TestingReport.vue

@@ -13,7 +13,7 @@
 
     <div class="report-leftRight">
       <!-- 自定义字段组件 -->
-      <custom v-if="reportHome === '自定义字段'" ref="custom" :custom="customList" @content="getCustom" @close="closeCustom" />
+      <custom v-if="reportHome === '自定义字段'" ref="custom" :custom="customList" :reporttype="'提测报告'" @content="getCustom" @close="closeCustom" />
 
       <!-- new模版 -->
       <newTestingTemplate

+ 102 - 21
src/views/reportManagement/components/template/customTemplate.vue

@@ -1,7 +1,7 @@
 <template>
   <el-row :gutter="20" class="Layout">
     <el-col v-for="(item, index) in customs" :key="index" :span="12">
-      <span v-show="item.bool" style="margin-bottom:20px;" class="Layout_space_between">
+      <span v-show="!show && isShow(item) || show && item.bool" style="margin-bottom:20px;" class="Layout_space_between">
         <span class="from-name"><span v-if="item.required" style="color: red;">*</span>{{ item.fieldName }} </span>
         <el-input v-if="item.type === 1" v-model="item.content" size="small" :disabled="disab" style="width:100%;" placeholder="请输入" @change="getFormValue" />
         <el-input v-if="item.type === 2" v-model="item.content" type="textarea" size="small" :disabled="disab" :rows="1" style="width:100%;" placeholder="请输入" @change="getFormValue" />
@@ -20,20 +20,34 @@
 export default {
   props: {
     custom: { type: Array, required: false, default: null },
+    baseFrom: { type: Object, required: false, default: null },
     disab: { type: Boolean, default: false }
   },
   data() {
     return {
-      customs: []
+      customs: [],
+      show: false
     }
   },
   watch: {
     custom: {
       handler(newV) {
+        this.customs = newV.map(e => e)
+        console.log(this.customs, '新的志')
         if (newV && newV[0].bool) {
-          this.customs = newV
+          this.show = true
+          this.customs.map(item => {
+            this.baseFrom[`${item.fieldKey}_${item.content}`] = item.content
+            if (item.contents && item.contents[0]) {
+              item.contents.map(elm => {
+                this.baseFrom[`${item.fieldKey}_${elm}`] = elm
+              })
+            }
+          })
+          console.log(this.customs, '新的志')
           return
         }
+        this.show = false
         this.customs = newV.map(item => ({
           ...item,
           bool: item.conditions === '默认展示' || this.getBoolValue(item.conditions)
@@ -43,6 +57,16 @@ export default {
     }
   },
   methods: {
+    isShow(item) {
+      if (item.conditions === '默认展示') {
+        return true
+      }
+      console.log(this.baseFrom, item.conditions, item)
+      if (this.baseFrom[item.conditions] === item.conditions.split('_')[1]) {
+        return true
+      }
+      return false
+    },
     getBoolValue(conditions) {
       const checkList = []
       this.customs.forEach(item => {
@@ -55,29 +79,86 @@ export default {
           })
         }
       })
-      console.log(checkList.indexOf(conditions) !== -1)
       return checkList.indexOf(conditions) !== -1
     },
     getFormValue(e) {
-      if (e) {
-        console.log(e)
-        this.customs.map(item => {
-          if (item.conditions === e.fieldKey + '_' + e.content || item.conditions === e.fieldKey + '_' + e.contents) {
-            item.bool = true
-            item.content = ''
-            item.contents = null
-          } else {
-            item.bool = item.conditions === '默认展示' || this.getBoolValue(item.conditions)
-          }
-          if (!item.bool) {
-            item.content = ''
-            item.contents = null
-          }
+      console.log(e)
+      this.show = false
+      const params = {}
+      const keys = []
+      this.customs.map(item => {
+        if (e.type < 4) {
+          item.conditions === `${e.fieldKey}_${e.content}` ? item.bool = true : ''
+        } else if (e.type === 4) {
+          e.contents.map(i => {
+            item.conditions === `${e.fieldKey}_${i}` ? item.bool = true : ''
+          })
+        }
+      })
+      // 单选
+      if (e.type === 3) {
+        params[`${e.fieldKey}_${e.content}`] = e.content
+      }
+      // 多选
+      if (e.type === 4) {
+        e.contents.forEach(elm => {
+          params[`${e.fieldKey}_${elm}`] = elm
         })
-        this.customs = [...this.customs]
       }
-      console.log(this.customs, '导出的结果')
-      this.$emit('formData', this.customs)
+      // 删除多余字段
+      Object.keys(this.baseFrom).forEach(key => {
+        if (key.indexOf(e.fieldKey) > -1) {
+          keys.push(key)
+        }
+      })
+      this.$emit('formData', {
+        customs: this.customs,
+        keys,
+        params
+      })
+    },
+    CustomSet(e) {
+      const key = Object.keys(e)[0]
+      const custom = {
+        followVersion: {
+          key: 'followVersion',
+          label: '是否跟版',
+          values: 0
+        },
+        isCodeReview: {
+          key: 'isCodeReview',
+          label: '是否codereview',
+          values: 1
+        }
+      }
+      const label = custom[key].label
+      // const value = e[key] + custom[key].values
+      const value = e[key]
+
+      // this.customs.forEach(elm => {
+      //   elm.conditions = ''
+      // })
+      const keys = []
+      const params = {
+        [`${label}_${value}`]: `${value}`
+      }
+      // 删除多余字段
+      Object.keys(this.baseFrom).forEach(key => {
+        if (key.indexOf(label) > -1) {
+          keys.push(key)
+        }
+      })
+      this.$emit('formData', {
+        customs: this.customs.map(e => e),
+        keys,
+        params
+      })
+      // this.$emit('formData', {
+      //   customs: this.customs,
+      //   keys,
+      //   params
+      // })
+      // console.log(e, this.customs, this.baseFrom, 'xcdjks ncjksdjnk')
     }
   }
 }

+ 27 - 4
src/views/reportManagement/daily/dailyTemplate.vue

@@ -29,7 +29,7 @@
       <el-form-item label="报告内容" style="margin-top: 20px;"><br>
 
         <!-- 自定义反显组件 -->
-        <moduleCustom v-if="customList && customList[0]" :custom="customList" :disab="false" @formData="formData" />
+        <moduleCustom v-if="customList && customList[0]" :custom="customList" :base-from="fromCreateData" :disab="false" @formData="formData" />
 
         <normal-area
           id="report-template-4"
@@ -162,13 +162,36 @@ export default {
       this.tasksDetailList.length <= 0 ? this.selectTask = true : this.selectTask = false
     },
 
-    formData(val) { // 编辑自定义字段获取content
-      this.fromCreateData = { ...this.fromCreateData, customFields: val }
-      console.log(val, 'cdcsdcs')
+    formData({ customs, keys, params }) { // 编辑自定义字段获取content
+      const newFrom = { ...this.fromCreateData, customFields: customs }
+      newFrom.customFields.forEach(elm => {
+        if (keys.indexOf(elm.conditions) > -1) {
+          elm.content = ''
+          elm.contents = []
+        }
+      })
+      keys.forEach(key => {
+        delete newFrom[key]
+      })
+      this.fromCreateData = { ...newFrom, ...params }
+      console.log(customs, params, 'customs')
     },
 
     // 新建
     getCreateData(val) {
+      let show = '0'
+      this.fromCreateData.customFields.map(item => {
+        if (item.bool && item.required && item.type < 4) {
+          item.type < 4 && item.content ? '' : show = item.fieldName
+        }
+        if (item.bool && item.required && item.type === 4) {
+          item.contents ? '' : show = item.fieldName
+        }
+      })
+      if (show !== '0') {
+        this.$message({ type: 'warning', message: `${show}不能为空` })
+        return
+      }
       if (this.selectTask) {
         this.$set(this.fromCreateData, 'taskIds', null)
         this.taskid_arr = []

+ 14 - 4
src/views/reportManagement/daily/newReportTemplate.vue

@@ -15,7 +15,7 @@
       </div>
 
       <!-- 自定义反显组件 -->
-      <moduleCustom v-if="customList && customList[0]" :custom="customList" :disab="true" @formData="formData" />
+      <moduleCustom v-if="customList && customList[0]" :custom="customList" :base-from="fromCreateData" :disab="true" @formData="formData" />
 
       <normal-area
         id="report-template-3"
@@ -153,9 +153,19 @@ export default {
       }, 200)
     },
 
-    formData(val) { // 编辑自定义字段获取content
-      this.fromCreateData = { ...this.fromCreateData, customFields: val }
-      console.log(val, 'cdcsdcs')
+    formData({ customs, keys, params }) { // 编辑自定义字段获取content
+      const newFrom = { ...this.fromCreateData, customFields: customs }
+      newFrom.customFields.forEach(elm => {
+        if (keys.indexOf(elm.conditions) > -1) {
+          elm.content = ''
+          elm.contents = []
+        }
+      })
+      keys.forEach(key => {
+        delete newFrom[key]
+      })
+      this.fromCreateData = { ...newFrom, ...params }
+      console.log(customs, params, 'customs')
     },
 
     customDialong() { // 点击自定义字段