Bläddra i källkod

新增专题库是添加事件

zhuliu 1 år sedan
förälder
incheckning
234685b60b
2 ändrade filer med 122 tillägg och 89 borttagningar
  1. 1 1
      src/utils/model/selectButton/index.vue
  2. 121 88
      src/views/project/components/drawer/form.vue

+ 1 - 1
src/utils/model/selectButton/index.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="selectButton">
     <div class="selectButton-div">
-      <slot name="select">
+      <slot>
         <el-select v-model="selectValue" :placeholder="placeholder" :size="size"
           :clearable="clearable" :disabled="disabled" :multiple="multiple" :filterable="filterable" @change="change">
           <el-option v-for="(item,index) in optionArr" :key="'myButton'+ index" :label="item[prop.label]" :value="item[prop.value]">

+ 121 - 88
src/views/project/components/drawer/form.vue

@@ -14,7 +14,7 @@
                 <el-form-item label="委托方" prop="entrustName" v-if="userinfo.tenantType == 1">
 
                   <mySelectButton size='large' style="width:100%" @click="handleSelect" >
-                    <div slot="select" style="width:100%">
+                    <div style="width:100%">
                       <el-autocomplete style="width:100%" v-model="ruleForm.entrustName" ref="client" value-key="name" :fetch-suggestions="querySearch" v-SelectLazyLoading="loadClient"
                         @input="input" placeholder="请输入内容" :trigger-on-focus="false" @select="handleChange">
                       </el-autocomplete>
@@ -37,40 +37,37 @@
                 </el-option>
               </el-select>
             </el-form-item>
-            <el-form-item label="事件" prop="event">
-              <div v-if="showEvent" style="display:flex">
-                <span>
-                  <el-tag
-                    v-for="tag in ruleForm.eventList"
-                    :key="tag.value"
-                    closable
-                    type='info'
-                    >
-                    {{tag.eventName}} - {{ tag.scenario }}
-                  </el-tag>
-                </span>
-                <span style="margin-left:10px">
-                  <my-cascader :options="eventList" @change="change">
-                    <i slot="reference" class="el-icon-circle-plus-outline" style="font-size:20px;"></i>
-                  </my-cascader>
-                </span>
-              </div>
-            </el-form-item>
-            <el-form-item label="应用场景" prop="scenarioIds">
-              <el-checkbox-group v-model="ruleForm.scenarioIds" @change="onChange">
-                <el-checkbox v-for="item in commonData" :key="item.id"
-                  :label="parseInt(item.id)">{{ item.name }}</el-checkbox>
-              </el-checkbox-group>
-            </el-form-item>
-            <el-form-item label="调查类型" prop="matterIds" v-if="show == true">
-              <el-checkbox-group v-model="ruleForm.matterIds">
-                <template >
-                  <el-checkbox v-for="(item, index) in dictAssociateData" :key="index" :label="parseInt(item.id)">
-                    {{ item.name }}
-                  </el-checkbox>
-                </template>
-              </el-checkbox-group>
+            <el-form-item label="事件" prop="event" v-if="!ruleForm.id">
+              <mySelectButton size='large' style="width:100%" @click="addEvent" >
+                    <div style="width:100%">
+                      <el-select style="width:100%" v-model="ruleForm.eventId" @change="changeEvent" filterable remote clearable placeholder="请选择"
+                        :loading="eventList.loading" v-SelectLazyLoading="loadEvent" :remote-method="remoteEvent">
+                        <el-option v-for="item in eventList.data" :key="item.id" :label="item.name" :value="item.id">
+                        </el-option>
+                      </el-select>
+                    </div>
+                  </mySelectButton>
             </el-form-item>
+            <template v-if="(ruleForm.id && !(ruleForm.eventIds && ruleForm.eventIds.length)) || !ruleForm.id">
+              <div>
+                <el-form-item label="应用场景" prop="scenarioIds">
+                  <el-checkbox-group v-model="ruleForm.scenarioIds" @change="onChange" :disabled="Boolean(ruleForm.eventId)">
+                    <el-checkbox v-for="item in commonData" :key="item.id"
+                      :label="parseInt(item.id)">{{ item.name }}</el-checkbox>
+                  </el-checkbox-group>
+                </el-form-item>
+                <el-form-item label="调查类型" prop="matterIds" v-if="show == true">
+                  <el-checkbox-group v-model="ruleForm.matterIds">
+                    <template >
+                      <el-checkbox v-for="(item, index) in dictAssociateData" :key="index" :label="parseInt(item.id)">
+                        {{ item.name }}
+                      </el-checkbox>
+                    </template>
+                  </el-checkbox-group>
+                </el-form-item>
+              </div>
+            </template>
+            
             <template>
               <div>
                 <el-form-item label="产品类别/产品" prop="productId" v-if="$permission('/workspace/product')">
@@ -221,23 +218,13 @@ export default {
         flag: 1
       },
       //事件列表
-      eventList:[
-        {
-          label:'事件1',
-          value:'1',
-          children:[
-            {
-              label:'1-1',
-              value:'3'
-            }
-          ]
-        },
-        {
-          label:'事件2',
-          value:'2'
+      eventList:{
+        queryParams:{
+          current:1,
+          size:10
         },
-      ],
-      showEvent:true,
+        data:[]
+      },
       //选择产品或产品类别
       productVisible:false,
       //委托方
@@ -303,43 +290,6 @@ export default {
       this.productVisible = false
     },
 
-    //选择事件
-    change(value){
-      if(this.ruleForm.eventList){
-        
-      }else{
-        this.ruleForm.eventList = []
-      }
-      var index = this.ruleForm.eventList.findIndex(item=>{
-        return item.eventId == value[0] && item.scenarioId == value[1]
-      })
-      if(index != -1){
-        this.$message.warning('该调查类型已存在')
-        this.showEvent = false
-        this.$nextTick(()=>{
-          this.showEvent = true
-        })
-        return false
-      }
-      var obj = {}
-        var arr = this.eventList.find(item=>{
-            return item.value == value[0]
-        })
-        obj.eventName = arr.label
-        obj.eventId = arr.value
-        if(value.length>1){
-          var arr2 = arr.children.find(item=>{
-                return item.value == value[1]
-              })
-          obj.scenario = arr2.label
-          obj.scenarioId = arr2.value
-        }
-      this.ruleForm.eventList.push(obj)
-      this.showEvent = false
-      this.$nextTick(()=>{
-        this.showEvent = true
-      })
-    },
 
     //打开弹窗
     async open(form, title) {
@@ -353,7 +303,15 @@ export default {
         this.ruleForm.scenarioIds = []
         this.show=false
       }
+
+      if(!this.ruleForm.id){
+        this.eventList.data = []
+        this.eventList.name = ''
+        this.getEventList()
+      }
+
       this.personnelList.data = []
+      this.personnelList.queryParams.name = ''
       if(this.ruleForm.headId){
         this.personnelList.queryParams.id = this.ruleForm.headId
         await this.getPersonnelList(1)
@@ -378,6 +336,66 @@ export default {
       });
     },
 
+    /**
+     * 事件
+     */
+    //打开事件弹窗
+    addEvent(){
+
+    },
+    //切换事件
+    changeEvent(val){
+      if(!val){
+        this.ruleForm.scenarioIds = []
+        this.show = false
+        this.ruleForm.matterIds = []
+        return 
+      }
+      var obj = this.eventList.data.find(item=>{
+        return item.id == val
+      })
+      if(obj){
+        this.ruleForm.scenarioIds = [obj.scenarioId]
+        this.show = true
+        this.onChange()
+      }
+    },
+    //懒加载事件
+    loadEvent(){
+      if(this.eventList.queryParams.current * this.eventList.queryParams.size>=this.eventList.queryParams.total){
+        return false
+      }
+      this.eventList.queryParams.current += 1
+      this.getEventList()
+    },
+    //远程搜索
+    remoteEvent(query){
+      this.eventList.data=[]
+      this.eventList.queryParams.current = 1
+      this.eventList.name = query
+      this.getPersonnelList()
+    },
+    //获取事件列表
+    async getEventList(){
+      this.eventList.loading = true;
+      let params = {
+        ...this.eventList.queryParams,//分页信息
+        searchQuery:this.eventList.name?`name=${this.eventList.name}`:'',//检索条件
+        orderDTOList: [
+          {
+            orderBy: "createTime",
+            orderType: 1
+          },
+        ]//排序
+      }
+      await this.$api.queryEvent(params).then(response => {
+        if(response.code == 200){
+          this.eventList.loading = false;
+          this.eventList.data.push(...response.data.data)
+          this.eventList.queryParams.total = response.data.total
+        }
+      })
+    },
 
     //获取人员列表(懒加载)
     loadHead(){
@@ -484,11 +502,25 @@ export default {
         if (valid) {
           this.show = false
           this.loading = true
-          console.log(this.ruleForm)
           this.ruleForm.trees = []
           if(this.ruleForm.products){
             this.ruleForm.trees.push(this.ruleForm.products)
           }
+          var scenarioIds = JSON.parse(JSON.stringify(this.ruleForm.scenarioIds))
+          if(this.ruleForm.eventId){
+            this.ruleForm.events = []
+            this.ruleForm.scenarioIds = []
+            this.ruleForm.matterIds.forEach(item=>{
+              this.ruleForm.events.push(
+                {
+                  matterId:item,
+                  scenarioId:scenarioIds[0],
+                  eventId:this.ruleForm.eventId
+                }
+              )
+            })
+          }
+         
           if (this.ruleForm.id) {
             this.$api.updatePatentProject(this.ruleForm).then(response => {
               this.loading = false
@@ -505,6 +537,7 @@ export default {
               this.$emit('submit', 1)
               this.close()
             }).catch(error => {
+              this.ruleForm.scenarioIds = JSON.parse(JSON.stringify(scenarioIds))
               this.show = true
               this.loading = false
             })