zhuhao 1 سال پیش
والد
کامیت
4bbe98d89a

+ 4 - 0
src/main.js

@@ -42,6 +42,10 @@ Vue.use(directive)
 import Cookies from "js-cookie";
 Vue.prototype.$cookie = Cookies
 
+//全局js
+import commonJS from '@/utils/common.js'
+Vue.prototype.$commonJS = commonJS
+
 import vmFunction from './utils/window'
 Vue.use(vmFunction)
 

+ 48 - 0
src/utils/common.js

@@ -0,0 +1,48 @@
+export default {
+  objectToString(val) {
+    var data = []
+    if (val.constructor == Object) {
+      if (Object.keys(val).length > 0) {
+        Object.keys(val).forEach(item => {
+          data.push(
+            {
+              key: item,
+              value: val[item]
+            }
+          )
+        })
+      } else {
+        return ''
+      }
+    } else if (val.constructor == Array) {
+      if (val.length > 0) {
+        data = val
+      } else {
+        return ''
+      }
+    } else {
+      return val
+    }
+    // 生成字符串
+    var str = ''
+    data.forEach(item => {
+      var value = ''
+      if (typeof item.value == 'object') {
+        value = '(' + item.value.join(' OR ') + ')'
+      } else {
+        if (item.value) {
+          value = item.value
+        } else {
+          return
+        }
+      }
+      if (str) {
+        str = str + ' AND ' + item.key + '=' + value
+      } else {
+        str = str + item.key + '=' + value
+      }
+
+    })
+    return str
+  },
+}

+ 279 - 227
src/views/event/components/dialog/addEvent.vue

@@ -1,131 +1,113 @@
 <template>
   <div class="addEvent">
-      <el-dialog
-          :title="title"
-          :visible.sync="dialogVisible"
-          :width="width"
-          :before-close="handleClose">
-           <!-- 单个新增(事件) -->
-          <div v-if="type == 1">
-              <el-form
-                  :model="formData[0]"
-                  :rules="rules"
-                  ref="ruleForm"
-                  label-width="100px"
-                  class="demo-ruleForm"
-              >
-                  <el-form-item label="事件名称" prop="questionName">
-                      <el-autocomplete
-                          class="inline-input"
-                          v-model="formData[0].questionName"
-                          :fetch-suggestions="querySearchQuestion"
-                          :placeholder="formData[0].placeholder?formData[0].placeholder:'请输入或选择事件'"
-                          :trigger-on-focus="false"
-                          @select="handleSelectQuestion"
-                          @change="change1($event,{$index:0})"
-                          @focus="focus($event,{$index:0})"
-                          @input="input1($event,{$index:0,
-                                          row:formData[0]})"
-                          style="width: 100%;" >
-                      </el-autocomplete>
-                  </el-form-item>
-                  <el-form-item label="事件日期" prop="eventDate">
-                      <el-date-picker style="width: 100%" v-model="formData[0].eventDate" :disabled="(formData[0].id && !this.row)?true:false" type="datetime"
-                          value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择事件日期时间">
-                      </el-date-picker>
-                  </el-form-item>
-                  <el-form-item label="事件描述" prop="description">
-                      <el-input type="textarea" :rows="1" v-model="formData[0].description" autocomplete="off"
-                          placeholder="请输入事件描述" :disabled="(formData[0].id && !this.row)?true:false"></el-input>
-                  </el-form-item>
-                  <el-form-item label="事件场景" prop="assistPerson">
-                      <el-select v-model="formData[0].applicationScenarios[0]" :disabled="(formData[0].id && !this.row)?true:false"  style="width: 100%;" placeholder="请选择事件场景">
-                          <el-option
-                              v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO ? commonData.ENTERPRISE_APPLICATION_SCENARIO : []"
-                              :key="parseInt(item.value)" :label="item.label" :value="parseInt(item.value)"
-                              >
-                          </el-option>
-                      </el-select>
-                  </el-form-item>
-              </el-form>
-          </div>
-          <!-- 批量新增(事件) -->
-          <div v-else-if="type == 2">
-              <el-table :data="formData" style="width: 100%" class="twj-table">
-              <el-table-column prop="questionName" label="事件名称" align="center">
-                  <template slot="header">
-                  <div>
-                      <el-tooltip class="item" effect="dark" content="事件:商业目标/解决问题/对应项目" placement="top">
-                      <span>事件名称<span style="color:red;"> *</span></span>
-                      </el-tooltip>
-                  </div>
-                  </template>
-                  <template slot-scope="scope">
-                  <div>
-                      <el-autocomplete
-                              class="inline-input"
-                              v-model="scope.row.questionName"
-                              :fetch-suggestions="querySearchQuestion"
-                              placeholder="请输入或选择事件"
-                              :trigger-on-focus="false"
-                              @select="handleSelectQuestion"
-                              @focus="focus($event,scope)"
-                              style="width: 100%;" >
-                      </el-autocomplete>
-                  </div>
-                  </template>
-              </el-table-column>
-              <el-table-column prop="eventDate" label="事件时间" align="center">
-                  <template slot-scope="scope">
-                  <div>
-                      <el-date-picker style="width: 100%" v-model="scope.row.eventDate" :disabled="scope.row.id?true:false" type="datetime"
-                      value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择事件日期时间">
-                      </el-date-picker>
-                  </div>
-                  </template>
-              </el-table-column>
-              <el-table-column prop="description" label="事件描述" align="center" width="250px">
-                  <template slot-scope="scope">
-                  <div>
-                      <el-input type="textarea" :rows="1" v-model="scope.row.description" autocomplete="off"
-                      placeholder="请输入事件描述" :disabled="scope.row.id?true:false"></el-input>
-                  </div>
-                  </template>
-              </el-table-column>
-              <el-table-column prop="applicationScenarios" label="事件场景" align="center" >
-                  <template slot-scope="scope">
-                  <div>
-                      <el-select v-model="scope.row.applicationScenarios[0]" :disabled="scope.row.id?true:false"  style="width: 100%;" placeholder="请选择事件场景">
-                      <el-option
-                          v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO ? commonData.ENTERPRISE_APPLICATION_SCENARIO : []"
-                          :key="parseInt(item.value)" :label="item.label" :value="parseInt(item.value)"
-                          >
-                      </el-option>
-                      </el-select>
-                  </div>
-                  </template>
-              </el-table-column>
-              <el-table-column label="事件操作" align="" width="100px">
-                  <template slot-scope="scope">
-                  <div>
-                      <el-tooltip class="item" effect="dark" content="增加事件" placement="top">
-                      <i @click="addRow(scope)" class="el-icon-plus btn"></i>
-                      </el-tooltip>
-                      <el-tooltip class="item" effect="dark" content="删除事件" placement="top">
-                      <i @click="deleteRow(scope)" v-if="scope.$index != 0" class="el-icon-close btn"></i>
-                      </el-tooltip>
-                  </div>
-                  </template>
-              </el-table-column>
-              </el-table>
-          </div>
-          <div slot="footer" class="dialog-footer">
-              <el-button type="primary" @click="submitForm1()" size="small" style="width:100px">确定</el-button>
-              <el-button size="small" @click="resetForm()" style="width:100px">重置</el-button>
-              <el-button size="small" @click="resetClose()" style="width:100px">取消</el-button>
-          </div>
-      </el-dialog>
-     
+    <el-dialog :title="title" :visible.sync="dialogVisible" :width="width" :before-close="handleClose">
+      <!-- 单个新增(事件) -->
+      <div v-if="type == 1">
+        <el-form :model="formData[0]" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
+          <el-form-item label="事件名称" prop="questionName">
+            <el-autocomplete class="inline-input" v-model="formData[0].questionName"
+              :fetch-suggestions="querySearchQuestion"
+              placeholder="请输入或选择事件" :trigger-on-focus="false"
+              @select="handleSelectQuestion" @change="change1($event, { $index: 0 })" @focus="focus($event, { $index: 0 })"
+              @input="input1($event, {
+                $index: 0,
+                row: formData[0]
+              })" style="width: 100%;">
+            </el-autocomplete>
+          </el-form-item>
+          <el-form-item label="事件日期" prop="eventDate">
+            <el-date-picker style="width: 100%" v-model="formData[0].eventDate"
+               type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
+              placeholder="选择事件日期时间">
+            </el-date-picker>
+          </el-form-item>
+          <el-form-item label="事件描述" prop="description">
+            <el-input type="textarea" :rows="1" v-model="formData[0].description" autocomplete="off" placeholder="请输入事件描述"
+              ></el-input>
+          </el-form-item>
+          <el-form-item label="事件场景" prop="assistPerson">
+            <el-select v-model="formData[0].applicationScenarios[0]" :disabled="(formData[0].id && !this.row) ? true : false"
+              style="width: 100%;" placeholder="请选择事件场景">
+              <el-option
+                v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO ? commonData.ENTERPRISE_APPLICATION_SCENARIO : []"
+                :key="parseInt(item.value)" :label="item.label" :value="parseInt(item.value)">
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-form>
+      </div>
+      <!-- 批量新增(事件) -->
+      <div v-else-if="type == 2">
+        <el-table :data="formData" style="width: 100%" class="twj-table">
+          <el-table-column prop="questionName" label="事件名称" align="center">
+            <template slot="header">
+              <div>
+                <el-tooltip class="item" effect="dark" content="事件:商业目标/解决问题/对应项目" placement="top">
+                  <span>事件名称<span style="color:red;"> *</span></span>
+                </el-tooltip>
+              </div>
+            </template>
+            <template slot-scope="scope">
+              <div>
+                <el-autocomplete class="inline-input" v-model="scope.row.questionName"
+                  :fetch-suggestions="querySearchQuestion" placeholder="请输入或选择事件" :trigger-on-focus="false"
+                  @select="handleSelectQuestion" @focus="focus($event, scope)" style="width: 100%;">
+                </el-autocomplete>
+              </div>
+            </template>
+          </el-table-column>
+          <el-table-column prop="eventDate" label="事件时间" align="center">
+            <template slot-scope="scope">
+              <div>
+                <el-date-picker style="width: 100%" v-model="scope.row.eventDate" :disabled="scope.row.id ? true : false"
+                  type="datetime" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择事件日期时间">
+                </el-date-picker>
+              </div>
+            </template>
+          </el-table-column>
+          <el-table-column prop="description" label="事件描述" align="center" width="250px">
+            <template slot-scope="scope">
+              <div>
+                <el-input type="textarea" :rows="1" v-model="scope.row.description" autocomplete="off"
+                  placeholder="请输入事件描述" :disabled="scope.row.id ? true : false"></el-input>
+              </div>
+            </template>
+          </el-table-column>
+          <el-table-column prop="applicationScenarios" label="事件场景" align="center">
+            <template slot-scope="scope">
+              <div>
+                <!-- multiple -->
+                <el-select v-model="scope.row.applicationScenarios[0]" :disabled="scope.row.id ? true : false"
+                  style="width: 100%;" placeholder="请选择事件场景">
+                  <el-option
+                    v-for="item in commonData.ENTERPRISE_APPLICATION_SCENARIO ? commonData.ENTERPRISE_APPLICATION_SCENARIO : []"
+                    :key="parseInt(item.value)" :label="item.label" :value="parseInt(item.value)">
+                  </el-option>
+                </el-select>
+              </div>
+            </template>
+          </el-table-column>
+          <el-table-column label="事件操作" align="" width="100px">
+            <template slot-scope="scope">
+              <div>
+                <el-tooltip class="item" effect="dark" content="增加事件" placement="top">
+                  <i @click="addRow(scope)" class="el-icon-plus btn"></i>
+                </el-tooltip>
+                <el-tooltip class="item" effect="dark" content="删除事件" placement="top">
+                  <i @click="deleteRow(scope)" v-if="scope.$index != 0" class="el-icon-close btn"></i>
+                </el-tooltip>
+              </div>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm1()" size="small" style="width:100px">确定</el-button>
+        <el-button size="small" @click="resetForm()" style="width:100px">重置</el-button>
+        <el-button size="small" @click="handleClose()" style="width:100px">取消</el-button>
+      </div>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -135,11 +117,11 @@ export default {
   data() {
     return {
       //弹窗标题
-      title:'',
+      title: '',
       //弹窗状态
-      dialogVisible:false,
+      dialogVisible: false,
       //弹窗宽度
-      width:'800px',
+      width: '800px',
       //表格数据
       formData: [
         {
@@ -150,38 +132,52 @@ export default {
         }
       ],
       //检验规则
-      rules:{},
+      rules: {
+        questionName: [ { required: true, message: '请输入事件名称', trigger: 'blur' },],
+      },
       //应用场景数据
       commonData: {},
       //弹窗类型
-      type:1,
+      type: 1,
     }
   },
   watch: {},
   async mounted() {
     // 应用场景(是通过字典还是接口待定)
     await this.getCommonData()
+    // 查询所有事件
+    // await this.questionEventList()
   },
   methods: {
-      //打开弹窗,判断是编辑还是添加,同时判断是批量添加还是添加单个事件(type==1是单个,type==2是批量)
-      open(data,type){
-          if(data){
-              this.formData = JSON.parse(JSON.stringify(data))
-          }else{
-              this.formData=[
-                  {
-                      questionName: '',
-                      eventDate: '',
-                      description: '',
-                      applicationScenarios: [],
-                  }
-              ]
+    //打开弹窗,判断是编辑还是添加,同时判断是批量添加还是添加单个事件(type==1是单个,type==2是批量)
+    open(data, type) {
+      this.type = type
+      if (data) {
+        this.title = '编辑事件'
+        this.formData[0] = JSON.parse(JSON.stringify(data))
+        console.log(this.formData);
+      } else {
+        if (this.type == 1) {
+          this.title='新增事件'
+        } else {
+          this.title='批量新增事件'
+        }
+        this.formData = [
+          {
+            questionName: '',
+            eventDate: '',
+            description: '',
+            applicationScenarios: [],
           }
-          this.type = type
-          this.dialogVisible = true
-      },
+        ]
+      }
+      this.dialogVisible = true
+    },
     //关闭弹窗
-    handleClose(){
+    handleClose() {
+      if (this.type=='1') {
+        this.$refs.ruleForm.resetFields()
+      }
       this.dialogVisible = false
     },
     // 请求应用场景(是通过字典还是接口待定)
@@ -191,71 +187,101 @@ export default {
       })
     },
     // 检验事件并提交保存请求
-    submitForm1(){
+    submitForm1() {
       var list = []
       try {
-        this.formData.forEach(item=>{
-          var a = false
-          for (let key in item) {
-            if (key != 'applicationScenarios') {
-              if(item[key]!='' && item[key]!=null){
-                    a = true
+        if (this.type=='1') {//单个新增事件
+          list=this.formData
+        } else {//多个新增事件
+          this.formData.forEach(item => {
+            var a = false
+            for (let key in item) {
+              if (key != 'applicationScenarios') {
+                if (item[key] != '' && item[key] != null) {
+                  a = true
                 }
-            } else {
-              if(item[key].length > 0){
-                    a = true
+              }else {
+                if (item[key].length > 0) {
+                  a = true
                 }
-            }  
-          }
-          if(a == true){
+              }
+            }
+            if (a == true) {
               if (item.questionName != '') {
-                    list.push(item)
+                list.push(item)
               } else {
                 throw new Error('事件名称不能为空')
               }
-          } 
-        })
-        var arr = [...new Set(list.map(item=>{return item.questionName}))]
-        if(arr.length<list.length){
+            }
+          })
+        }
+        var arr = [...new Set(list.map(item => { return item.questionName }))]
+        if (arr.length < list.length) {
           this.$message.error(`存在重复的事件名称,请重定义事件名称`)
           return false
         }
         var edit = false
-        if(this.row){
+        if (this.row) {
           edit = true
         }
-         this.$emit('formData', {list:list,option:1,edit})
+        this.addFormData({ list: list, option: 1, edit })
+        // this.$emit('formData', { list: list, option: 1, edit })
       } catch (error) {
         this.$message.error(error)
       }
     },
-     //取消全部事件
+    // 提交保存事件
+    addFormData(val) {
+      let lists = JSON.parse(JSON.stringify(val.list))
+      let forms = {
+        projectId: this.projectId,
+        eventAddNewDTOs:lists
+      }
+      if (this.type=='1') {//单个事件新增
+        this.$refs.ruleForm.validate(valid => {
+          if (valid) {
+            this.addInterface(forms)
+          } 
+        })
+      } else {//多个事件新增
+        this.addInterface(forms)
+      }
+    },
+    //提交保存事件接口
+    addInterface(forms) {
+      this.$api.eventAddNew(forms).then(res => {
+        if (res.code == 200) {
+          this.$emit('isSuccess','新增成功')
+          this.$message.success('事件新增成功')
+          this.handleClose()
+        }
+      }).catch(error => {
+        this.$message.error(error.message)
+      })
+    },
+    //重置全部事件
     resetForm() {
       this.$confirm('此操作将重置全部事件, 是否继续?', '提示', {
-          confirmButtonText: '确定',
-          cancelButtonText: '取消',
-          type: 'warning'
-        }).then(() => {
-          if(this.type ==1 ){
-              this.$refs.ruleForm.resetFields();
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        if (this.type == 1) {
+          this.$refs.ruleForm.resetFields();
+        }
+        this.formData = [
+          {
+            questionName: '',
+            eventDate: '',
+            description: '',
+            applicationScenarios: [],
           }
-          this.formData=[
-              {
-                questionName: '',
-                eventDate: '',
-                description: '',
-                applicationScenarios: [],
-              }
-          ]
-          // this.$emit('formData', {list:this.formData,option:1})
-          this.$message.success('事件已全部重置')
-        }).catch(() => {   
-          this.$message.info('重置操作已取消')
-        });
-    },
-    // 关闭弹窗并清空数据
-    resetClose() {
-      this.$emit('resetClose',true)
+        ]
+        // this.$emit('formData', {list:this.formData,option:1})
+        this.$message.success('事件已全部重置')
+      }).catch(() => {
+        this.$message.info('重置操作已取消')
+      });
     },
     // 增加事件
     addRow() {
@@ -270,63 +296,88 @@ export default {
     },
     //删除事件
     deleteRow(row) {
-        this.formData.splice(row.$index,1)
+      this.formData.splice(row.$index, 1)
     },
-    // 查询事件
+    // 查询所有事件
     async questionEventList() {
       await this.$api.eventQuery({}).then(res => {
-        if (res.code==200) {
+        if (res.code == 200) {
           this.questionNameArr = res.data.list
         }
       })
     },
-    //通过接口获取建议数据
+    //获取下拉建议数据
     querySearchQuestion(queryString, cb) {
-      
+      var restaurants = this.questionNameArr.map(item => {
+        item.value = item.questionName;
+        return item;
+      });
+      var results = queryString ? restaurants.filter(this.createFilterQuestion(queryString)) : restaurants;
+      // 调用 callback 返回建议列表的数据
+      cb(results);
+    },
+    // 对下拉建议列表的数据进行处理
+    createFilterQuestion(queryString) {
+      return (restaurant) => {
+        console.log(restaurant);
+          return (restaurant.value.indexOf(queryString) != -1);
+      };
     },
     // input框切换选择
-      handleSelectQuestion(val) {
-          let a=this.formData.findIndex(item => {
-              return item.id == val.id
-          })
-          
-          if (a == -1) {
-              // this.$set(this.formData,this.index,JSON.parse(JSON.stringify(val)))
-          } else {
-              this.$message.error('事件已存在')
-              this.$set(this.formData,this.index,{})
-              return false
-          }
-      },
-      //失去焦点
-      focus(ev,val){
-          
-      },
+    handleSelectQuestion(val) {
+      let a = this.formData.findIndex(item => {
+        return item.id == val.id
+      })
+      if (a == -1) {
+        // this.$set(this.formData,this.index,JSON.parse(JSON.stringify(val)))
+      } else {
+        this.$message.error('事件已存在')
+        this.$set(this.formData, this.index, {})
+        return false
+      }
+    },
+    //失去焦点
+    focus(ev, val) {
+
+    },
+    // input事件
+    input1(ev, val) {
+      // console.log(ev,val);
+    },
+    // change事件,input值改变触发
+    change1(val) {
+      // console.log(val);
+    },
   },
 }
 </script>
 
 <style lang="scss">
-.addEvent{
-  .dialog-footer{
-      text-align: center;
+.addEvent {
+  .dialog-footer {
+    text-align: center;
   }
 }
-.twj-table td.el-table__cell, .twj-table th.el-table__cell.is-leaf{
-    // border:none !important;
-    border:5px solid white !important;
+
+.twj-table td.el-table__cell,
+.twj-table th.el-table__cell.is-leaf {
+  // border:none !important;
+  border: 5px solid white !important;
 }
+
 .twj-table::before {
-    background-color: transparent;
+  background-color: transparent;
 }
-.twj-table tr td:first-child{
+
+.twj-table tr td:first-child {
   border-right: none !important;
   border-left: none !important;
-  }
-.twj-table tr td:last-child{
-      border-right: none !important;
-      border-left:none !important;
-  }
+}
+
+.twj-table tr td:last-child {
+  border-right: none !important;
+  border-left: none !important;
+}
 </style>
 <style lang="scss">
 .btn {
@@ -336,6 +387,7 @@ export default {
   text-align: center;
   cursor: pointer;
 }
+
 .btn:hover {
   color: aqua;
 }

+ 102 - 14
src/views/event/components/index.vue

@@ -43,6 +43,7 @@
             :commonData="commonData"
             @on-sort="handleSort"
             @option="handleOption"
+            @sort="sortChange"
           ></component>
         </div>
       </el-main>
@@ -60,7 +61,7 @@
       </el-footer>
     </el-container>
 
-    <addEvent ref="addEvent"></addEvent>
+    <addEvent ref="addEvent"  @isSuccess="handleSuccess"></addEvent>
   </div>
 </template>
 
@@ -90,7 +91,19 @@ export default {
           value: 'questionName',
           type: 1,
           placeholder: '请输入事件名称'
-        }
+        },
+        {
+          label: '相关报告',
+          value: 'report',
+          type: 1,
+          placeholder: '请输入相关报告'
+        },
+        {
+          label: '相关专题库',
+          value: 'project',
+          type: 1,
+          placeholder: '请输入相关专题库'
+        },
       ],
       //检索条件
       searchOption: {
@@ -123,7 +136,9 @@ export default {
       //加载中
       loading: false,
       //事件的数据集合
-      tableData: [{}],
+      tableData: [
+        { questionName: '事件名称', eventNumber: 2, projectNumber: 3, applicationScenarios: [1],eventDate:'2023-10-25',description:'事件描述'},
+      ],
       //分页信息
       queryParams: {
         current: 1,
@@ -148,6 +163,25 @@ export default {
     this.getColumn()
   },
   methods: {
+    // 子组件table排序
+    sortChange({ column, prop, order }) {//des,acs
+      this.sort.data=prop
+      if (order == 'ascending') {
+        this.sort.orderAsc = 'asc'
+      } else {
+        this.sort.orderDes='des'
+      }
+    },
+    // 子组件新增事件成功
+    handleSuccess(val) {
+      // console.log(val);
+      this.queryParams.current = 1
+      if (this.groupingValue == 'noGrouping') {//不分组
+        this.getList()
+      } else {//分组
+        this.getGrouping()
+      }
+    },
     //显示视图
     showViews() {
       this.showView = false
@@ -159,7 +193,7 @@ export default {
     getColumn() {
       this.columnList = [
         {
-          "key": "name",
+          "key": "questionName",
           "name": "事件名称",
           "type": "list",
           "order": 0,
@@ -180,28 +214,28 @@ export default {
           "hidden": true
         },
         {
-          "key": "projectNumber1",
+          "key": "applicationScenarios",
           "name": "事件场景",
           "type": "list",
           "order": 0,
           "hidden": true
         },
         {
-          "key": "projectNumber2",
+          "key": "eventDate",
           "name": "事件时间",
           "type": "list",
           "order": 0,
           "hidden": true
         },
         {
-          "key": "projectNumber3",
+          "key": "description",
           "name": "描述",
           "type": "list",
           "order": 0,
           "hidden": true
         },
         {
-          "key": "projectNumber4",
+          "key": "createPerson",
           "name": "创建人",
           "type": "list",
           "order": 0,
@@ -222,8 +256,21 @@ export default {
     },
     //获取检索条件检索
     search(val) {
-
+      let params={}
+      val.forEach(item => {
+        params[item.value]=item.searchValue.label
+      })
+      // 返回字符串
+      // let str=this.$commonJS.objectToString(params)
+      // 调用查询接口
+      // this.$api.query(params).then(res => {
+      //   if (res.code == 200) {
+      //     this.queryParams.current=1
+      //     this.getList()
+      //   }
+      // })
     },
+   
 
     // 分页
     handleCurrentChange(val) {
@@ -233,12 +280,31 @@ export default {
 
     //查询事件数据
     getList() {
-
+      let params = {
+        ...this.queryParams,//分页信息
+        ...this.sort,//排序
+        ...this.searchOption,//检索条件
+      }
+      // this.$api.query(params).then(res => {
+      //   if (res.code == 200) {
+      //    this.tableData = rea.data
+      //   }
+      // })
     },
 
     //切换分组值
     changeGrouping(val) {
 
+      this.getGrouping()
+    },
+    // 调用分组查询的方法
+    getGrouping() {
+      this.queryParams.current = 1
+      // this.$api.query(params).then(res => {
+      //   if (res.code == 200) {
+      //    this.tableData = rea.data
+      //   }
+      // })
     },
 
     //切换视图
@@ -257,21 +323,43 @@ export default {
 
     },
 
-    //表格操作列(option为操作类型,row为当前行数据,type为报告类型)
+    //表格操作列(option为操作类型,row为当前行数据,type为报告类型,单件事件弹窗为1)
     handleOption({ option, row, type }) {
       switch (option) {
-        case '1'://新增专题库
+        case '0'://新增专题库
           break;
         case 'addReport'://新增报告
           break;
-        case '3'://删除
+        case '10'://删除
+          this.eventDelete()
           break;
         case 'cancel'://取消关联
           break;
-        case 'edit'://编辑事件
+        case 'edit'://编辑事件,打开单件事件弹窗
+          this.$refs.addEvent.open(row,1)
           break;
       }
     },
+    // 删除事件
+    eventDelete() {
+      this.$confirm('此操作将删除该事件, 是否继续?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        // 调用接口
+        this.$message({
+          type: 'success',
+          message: '删除成功!'
+        });
+        this.getList()
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消删除'
+        });
+      });
+    },
   },
 };
 </script>

+ 68 - 68
src/views/event/components/mixins/index.js

@@ -1,75 +1,75 @@
 import { checkVisual } from "@/views/home/components/mixins";
-export default{
-    mixins:[checkVisual],
-    props:{
-      tableData: {//数据
-        type: Array,
-        default: () => {
-          return [{ name: '123', eventNumber: 2, projectNumber: 3, projectNumber1: [{ name: '场景一' }, {name:'场景二'}]},{},{},{},]
-        }
-      },
-      queryParams: {//分页信息
-        type: Object,
-        default: () => {
-          return {
-            size: 10,
-            current: 1,
-          }
+export default {
+  mixins: [checkVisual],
+  props: {
+    tableData: {//数据
+      type: Array,
+      default: () => {
+        return []
+      }
+    },
+    queryParams: {//分页信息
+      type: Object,
+      default: () => {
+        return {
+          size: 10,
+          current: 1,
         }
-      },
-    },  
-    computed:{
-        dictMessage() {
-          var a = JSON.parse(JSON.stringify(this.$store.state.dictMessage.dictMessage))
-          if(a.REPORT_TYPE){
-            a.REPORT_TYPE.forEach(item=>{
-              if(['0','1','2'].includes(item.dictChildValue)){
-                item.permission = 'invalid'
-              }else if(item.dictChildValue == 3){
-                item.permission = 'FTO'
-              }else if(item.dictChildValue == 4){
-                item.permission = 'tort'
-              }else if(item.dictChildValue == 5){
-                item.permission = 'avoidDesign'
-              }else if (item.dictChildValue == 7) {
-                item.permission = 'reInvalid'
-              }
-            })
+      }
+    },
+  },
+  computed: {
+    dictMessage() {
+      var a = JSON.parse(JSON.stringify(this.$store.state.dictMessage.dictMessage))
+      if (a.REPORT_TYPE) {
+        a.REPORT_TYPE.forEach(item => {
+          if (['0', '1', '2'].includes(item.dictChildValue)) {
+            item.permission = 'invalid'
+          } else if (item.dictChildValue == 3) {
+            item.permission = 'FTO'
+          } else if (item.dictChildValue == 4) {
+            item.permission = 'tort'
+          } else if (item.dictChildValue == 5) {
+            item.permission = 'avoidDesign'
+          } else if (item.dictChildValue == 7) {
+            item.permission = 'reInvalid'
           }
-          if(a.REPORT_TYPE){
-            a.REPORT_TYPE.push(
-                {
-                    dictChildValue:'w',
-                    dictChildLabel:'专利挖掘',
-                    permission : 'reInvalid'
-                },
-                {
-                    dictChildValue:'e',
-                    dictChildLabel:'其他',
-                    permission : 'reInvalid'
-                }
-            )
+        })
+      }
+      if (a.REPORT_TYPE) {
+        a.REPORT_TYPE.push(
+          {
+            dictChildValue: 'w',
+            dictChildLabel: '专利挖掘',
+            permission: 'reInvalid'
+          },
+          {
+            dictChildValue: 'e',
+            dictChildLabel: '其他',
+            permission: 'reInvalid'
           }
-          
-          return a
-        },
+        )
+      }
+
+      return a
     },
-    methods: {
-        // 取消与专题库的关联
-        handleDelete(row) {
-            this.$emit('option', { option:'cancel', row })
-        },
-        //操作列事件
-        handleCommand(option,row){
-            this.$emit('option', { option, row })
-        },
-        //新增报告
-        handleAnalyse(type,row) {
-            this.$emit('option', { option:'addReport', row, type })
-        },
-        //编辑事件
-        handleClick(row){
-            this.$emit('option', { option:'edit', row })
-        }
+  },
+  methods: {
+    // 取消与专题库的关联
+    handleDelete(row) {
+      this.$emit('option', { option: 'cancel', row })
+    },
+    //操作列事件
+    handleCommand(option, row) {
+      this.$emit('option', { option, row })
+    },
+    //新增报告
+    handleAnalyse(type, row) {
+      this.$emit('option', { option: 'addReport', row, type })
     },
+    //编辑事件
+    handleClick(row) {
+      this.$emit('option', { option: 'edit', row })
+    }
+  },
 }

+ 1 - 1
src/views/event/components/view/mergeTable.vue

@@ -104,7 +104,7 @@ export default {
     },
     //打开展开行获取数据并保存起来
     expandChange() {
-
+      
     }
   }
 }

+ 17 - 12
src/views/event/components/view/table.vue

@@ -1,24 +1,25 @@
 <template>
   <div class="eventTable height_100">
-    <el-table :data="tableData" header-row-class-name="custom-table-header">
+    <el-table :data="tableData" header-row-class-name="custom-table-header" @sort-change="sortChange">
       <el-table-column label="#" width="60" type="index" align="center">
         <template slot-scope="scope">
           <span>{{ (scope.$index + 1) + ((queryParams.current - 1) * queryParams.size) }}</span>
         </template>
       </el-table-column>
 
-      <el-table-column v-for="item in column" :key="item.key" :prop="item.key" :label="item.name" align="center">
+      <el-table-column v-for="item in column" :key="item.key" :prop="item.key" :label="item.name" align="center" sortable="custom">
         <template slot-scope="scope">
-          <div v-if="['name', 'eventNumber', 'projectNumber'].includes(item.key)">
+          <div v-if="['questionName', 'eventNumber', 'projectNumber'].includes(item.key)">
             <el-link @click="handleItem(scope.row, item.key)">{{ scope.row[item.key] }}</el-link>
           </div>
-          <div v-else v-html="getColumnData(scope.row, item.key)"></div>
+          <div v-else-if="['applicationScenarios'].includes(item.key)" v-html="getColumnData(scope.row, item.key)"></div>
+          <div v-else>{{ scope.row[item.key] }}</div>
         </template>
       </el-table-column>
 
-        <el-table-column v-if="['首页'].indexOf(isOperate) == -1" label="操作" align="center" width="150px">
+        <el-table-column v-if="['首页'].indexOf(isOperate) == -1" label="操作" align="center" width="150px" >
           <template slot-scope="scope">
-            <el-dropdown split-button type="primary" size="small" @click="handleClick($event,scope.row)"
+            <el-dropdown split-button type="primary" size="small" @click="handleClick(scope.row)"
               @command="handleCommand($event,scope.row)">
               <p>编 辑</p>
               <el-dropdown-menu slot="dropdown" style="text-align:center">
@@ -54,7 +55,7 @@ export default {
       default: () => {
         return [
           {
-            "key": "name",
+            "key": "questionName",
             "name": "事件名称",
             "type": "list",
             "order": 0,
@@ -75,28 +76,28 @@ export default {
             "hidden": true
           },
           {
-            "key": "projectNumber1",
+            "key": "applicationScenarios",
             "name": "事件场景",
             "type": "list",
             "order": 0,
             "hidden": true
           },
           {
-            "key": "projectNumber2",
+            "key": "eventDate",
             "name": "事件时间",
             "type": "list",
             "order": 0,
             "hidden": true
           },
           {
-            "key": "projectNumber3",
+            "key": "description",
             "name": "描述",
             "type": "list",
             "order": 0,
             "hidden": true
           },
           {
-            "key": "projectNumber4",
+            "key": "createPerson",
             "name": "创建人",
             "type": "list",
             "order": 0,
@@ -125,13 +126,17 @@ export default {
 
   },
   methods: {
+    // 排序
+    sortChange({ column, prop, order }) {
+      this.$emit('sort',{ column, prop, order })
+    },
     // 点击名称等事件
     handleItem(row, key) {
       // console.log(row,key);
     },
     // 
     getColumnData(row, key) {
-      if (key == 'projectNumber1') {
+      if (key == 'applicationScenarios') {
         if (row[key]) {
           var a = ''
           row[key].forEach(item => {

+ 55 - 55
src/views/home/components/mixins.js

@@ -4,61 +4,61 @@
 // Vue.use(showDialog)
 
 export const checkVisual = {
-    methods: {
-         //查看可视化
-        checkVisual(Scenario,eventId,eventName){
-            // this.$showDialog({
-            //     Scenario:Scenario,
-            //     eventId:eventId,
-            //     eventName:eventName
-            // },true);
-            this.$emit('checkVisual',{
-                Scenario:Scenario,
-                eventId:eventId,
-                eventName:eventName
-            })
-        },
-        handleDownload(row) {
-            var FileUrl =  `http://${this.$c.hostname}:8012/onlinePreview?url=`+ btoa(encodeURIComponent(this.$p + row.url))
-            // var FileUrl =  `http://192.168.1.24:8012/onlinePreview?url=`+ btoa(encodeURIComponent(this.$p + row.url))
-            const router = this.$router.resolve({
-                    path: '/checkFile',
-                    query: {
-                      row: JSON.stringify(row),
-                      FileUrl: FileUrl,
-                      isPicture:0
-                  }
-              })
-              window.open(router.href, '_blank');
-          },
-    }
+  methods: {
+    //查看可视化
+    checkVisual(Scenario, eventId, eventName) {
+      // this.$showDialog({
+      //     Scenario:Scenario,
+      //     eventId:eventId,
+      //     eventName:eventName
+      // },true);
+      this.$emit('checkVisual', {
+        Scenario: Scenario,
+        eventId: eventId,
+        eventName: eventName
+      })
+    },
+    handleDownload(row) {
+      var FileUrl = `http://${this.$c.hostname}:8012/onlinePreview?url=` + btoa(encodeURIComponent(this.$p + row.url))
+      // var FileUrl =  `http://192.168.1.24:8012/onlinePreview?url=`+ btoa(encodeURIComponent(this.$p + row.url))
+      const router = this.$router.resolve({
+        path: '/checkFile',
+        query: {
+          row: JSON.stringify(row),
+          FileUrl: FileUrl,
+          isPicture: 0
+        }
+      })
+      window.open(router.href, '_blank');
+    },
   }
+}
 
-  export const openVisual = {
-    methods: {
-        //查看可视化
-        checkVisual({Scenario,eventId,eventName}){
-            if(Scenario && Scenario.length>0){
-                var visuals = {
-                    Scenario:Scenario,
-                    eventId:eventId,
-                    eventName:eventName
-                }
-                if(eventId){
-                    this.$router.push({
-                        path:'/eventVisual',
-                        query:{
-                            visuals:JSON.stringify(visuals)
-                        }
-                    })
-                    return false 
-                }
-                this.$refs.visualDialog.open(visuals)
-            }else{
-                this.$message.error('该事件下没有应用场景')
+export const openVisual = {
+  methods: {
+    //查看可视化
+    checkVisual({ Scenario, eventId, eventName }) {
+      if (Scenario && Scenario.length > 0) {
+        var visuals = {
+          Scenario: Scenario,
+          eventId: eventId,
+          eventName: eventName
+        }
+        if (eventId) {
+          this.$router.push({
+            path: '/eventVisual',
+            query: {
+              visuals: JSON.stringify(visuals)
             }
-            
-        },
-      
-    }
-  }
+          })
+          return false
+        }
+        this.$refs.visualDialog.open(visuals)
+      } else {
+        this.$message.error('该事件下没有应用场景')
+      }
+
+    },
+
+  }
+}