index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  1. <template>
  2. <div class="height_100">
  3. <el-container v-if="showView">
  4. <el-header>
  5. <div id="step1">
  6. <mySearch style="width: 500px" :SearchFields="searchFiled" @search="search" :searchValue="searchOption">
  7. </mySearch>
  8. </div>
  9. <div style="display: flex">
  10. <div v-if="[2].indexOf(isOperate) == -1" id="step2">
  11. <span>分组查询:</span>
  12. <el-select v-model="groupingValue" size="small" @change="changeGrouping" clearable style="width: 120px">
  13. <el-option v-for="item in groupingOption" :key="item.value" :label="item.name" :value="item.value">
  14. </el-option>
  15. </el-select>
  16. </div>
  17. <el-button-group id="step3" style=" display: flex; justify-content: flex-start; margin-left: 10px;" v-if="[2].indexOf(isOperate) == -1">
  18. <!-- <el-button size="small" :type="viewSelectedBtn === 'visual' ? 'primary' : ''" @click="onChange2('visual')">可视化</el-button> -->
  19. <el-button :type="viewSelectedBtn === 'Table' ? 'primary' : ''" @click="onChange2('Table')" size="small">列表</el-button>
  20. <el-button :type="viewSelectedBtn === 'Card' ? 'primary' : ''" @click="onChange2('Card')" size="small">卡片</el-button>
  21. </el-button-group>
  22. <!-- <el-button type="primary" size="small" style="margin: 0 10px;" @click="handleCommand('1')">添加事件</el-button> -->
  23. <el-dropdown id="step4" trigger="click" split-button type="primary" size="small" @command="handleCommand($event)">
  24. <span @click="handleCommand('1')">添加事件</span>
  25. <el-dropdown-menu slot="dropdown" class="text-align_center">
  26. <el-dropdown-item command="3">显示栏位管理</el-dropdown-item>
  27. <!-- <el-dropdown-item command="2">批量添加事件</el-dropdown-item> -->
  28. </el-dropdown-menu>
  29. </el-dropdown>
  30. </div>
  31. </el-header>
  32. <el-main id="patent-list-container" class="main" v-loading="loading">
  33. <div class="height_100">
  34. <component
  35. v-if="showView"
  36. ref="questionViewList"
  37. :is="viewSelected"
  38. v-bind="$attrs"
  39. v-on="$listeners"
  40. :isOperate="isOperate"
  41. :queryParams="queryParams"
  42. :tableData="tableData"
  43. :column="columnList"
  44. :commonData="commonData"
  45. @on-sort="handleSort"
  46. @option="handleOption"
  47. :groupBy='groupingValue'
  48. :groupingOption="groupingOption"
  49. :searchOption="searchOption"
  50. :sign="true"
  51. :scenarioName="scenarioName"
  52. @toFlowPath="toFlowPath"
  53. :handleMessage="handleMessage"
  54. ></component>
  55. </div>
  56. </el-main>
  57. <el-footer class="pagination" v-if="viewSelectedBtn != 'visual'">
  58. <el-pagination
  59. background
  60. layout="total, sizes, prev, pager, next, jumper"
  61. :current-page.sync="queryParams.current"
  62. :page-size.sync="queryParams.size"
  63. @current-change="handleCurrentChange"
  64. @size-change="changeSize"
  65. :total="total"
  66. >
  67. </el-pagination>
  68. </el-footer>
  69. </el-container>
  70. <addEvent ref="addEvent" @isSuccess="handleSuccess"></addEvent>
  71. <fields ref="field" type="event" @getFieldList="getFieldList"></fields>
  72. </div>
  73. </template>
  74. <script>
  75. import Table from './view/table.vue'
  76. import Card from './view/card.vue'
  77. import visual from '@/views/visual/components/sceneSVG.vue';
  78. import flowPath from '@/views/visual/title/index.vue'
  79. import mergeTable from './view/mergeTable.vue';
  80. import addEvent from './dialog/addEvent.vue';
  81. import fields from '@/views/components/dialog/fields.vue';
  82. export default {
  83. components: {
  84. Table,
  85. Card,
  86. visual,
  87. flowPath,
  88. mergeTable,
  89. addEvent,
  90. fields
  91. },
  92. props: {
  93. eventName:'',
  94. scenarioId:null,
  95. isOperate:''
  96. },
  97. data() {
  98. return {
  99. //检索字段
  100. searchFiled: [],
  101. //检索条件
  102. searchOption: {
  103. scenarioNames:this.scenarioId || (localStorage.scenarioName?[Number(localStorage.scenarioName)]:''),
  104. name:this.eventName || localStorage.searchContent
  105. },
  106. //分组的值
  107. groupingValue: '',
  108. //分组
  109. groupingOption: [],
  110. // 当前显示的视图
  111. viewSelected: 'Table',
  112. // 三种视图底色
  113. viewSelectedBtn:'Table',
  114. //加载中
  115. loading: false,
  116. //事件的数据集合
  117. tableData: [],
  118. //分页信息
  119. queryParams: {
  120. current: 1,
  121. size: 10
  122. },
  123. //总条数
  124. total: 0,
  125. //排序
  126. sort: [
  127. {
  128. "orderBy": "createTime",
  129. "orderType": 1
  130. }
  131. ],
  132. //显示栏位
  133. columnList: null,
  134. //分组数据
  135. commonData: [],
  136. //显示视图
  137. showView: false,
  138. //操作回馈
  139. handleMessage:'',
  140. //应用场景名称
  141. scenarioName:''
  142. };
  143. },
  144. watch: {
  145. },
  146. computed: {
  147. scene(){
  148. var a = this.$store.state.dictMessage.scenario.map(item=>{
  149. return {
  150. label:item.name,
  151. value:item.id
  152. }
  153. })
  154. var obj = this.searchFiled.find(item=>{return item.label == '应用场景'})
  155. if(obj){
  156. obj.options = a
  157. }
  158. return this.$store.state.dictMessage.scenario
  159. }
  160. },
  161. created() { },
  162. async mounted() {
  163. this.columnList = await this.$commonJS.getCustomField('event')
  164. //获取table栏位及分组字段
  165. await this.getColumn()
  166. this.getList()
  167. },
  168. methods: {
  169. //打开应用场景处理流程界面
  170. toFlowPath(title){
  171. this.scenarioName = title
  172. this.viewSelected = 'flowPath'
  173. },
  174. //显示栏位管理
  175. getFieldList(data){
  176. this.columnList = []
  177. this.$nextTick(()=>{
  178. this.columnList = data
  179. })
  180. },
  181. // 子组件新增事件成功
  182. handleSuccess(val) {
  183. this.handleMessage = val
  184. this.queryParams.current = 1
  185. this.isGrouping()
  186. this.clearMessage()
  187. },
  188. //清空信息
  189. clearMessage(){
  190. this.$emit('submit',true)
  191. this.$nextTick(()=>{
  192. this.handleMessage = ''
  193. })
  194. },
  195. //显示视图?
  196. showViews() {
  197. this.showView = false
  198. this.$nextTick(() => {
  199. this.showView = true
  200. })
  201. },
  202. //获取table栏位及分组字段、检索字段
  203. async getColumn() {
  204. let params = ['event']
  205. await this.$api.getParamsCommon(params).then(res => {
  206. if (res.code == 200) {
  207. let conditionDTOList= JSON.parse(JSON.stringify(res.data[0].conditionDTOList))
  208. // 分组字段
  209. this.groupingOption = this.$commonJS.getField(conditionDTOList,(u)=> u.ifGroup == true,{
  210. name: 'name',
  211. value: 'value',
  212. })
  213. // 搜索字段
  214. this.searchFiled = this.$commonJS.getField(conditionDTOList,(u)=> u.ifSearch == true ,{
  215. label: 'name',
  216. value: 'value',
  217. type:'type',
  218. })
  219. //为应用场景添加选项
  220. var obj = this.searchFiled.find(item=>{return item.label == '应用场景'})
  221. if(obj){
  222. obj.options = this.scene.map(item=>{
  223. return {
  224. label:item.name,
  225. value:item.id
  226. }
  227. })
  228. }
  229. }
  230. })
  231. this.showViews()
  232. },
  233. //获取检索条件检索
  234. search(val) {
  235. let params = {}
  236. val.forEach(item => {
  237. if (item.type == 3) {
  238. params[item.value]=item.searchValue.map(itemValue => {
  239. return itemValue.value
  240. })
  241. } else {
  242. params[item.value]=item.searchValue.value
  243. }
  244. })
  245. // 返回条件对象
  246. this.searchOption=this.$commonJS.ArrayToArray(val)
  247. // 调用查询接口
  248. this.queryParams.current=1
  249. this.isGrouping()
  250. },
  251. // 分页
  252. handleCurrentChange(val) {
  253. this.queryParams.current = val;
  254. this.isGrouping()
  255. },
  256. //切换页大小
  257. changeSize(val){
  258. this.queryParams.size = val
  259. this.queryParams.current = 1
  260. this.isGrouping()
  261. },
  262. //查询事件数据
  263. getList() {
  264. let params = {
  265. ...this.queryParams,//分页信息
  266. searchQuery:this.$commonJS.objectToString(this.searchOption || {}),//检索条件
  267. orderDTOList: this.sort,//排序
  268. }
  269. this.$api.queryEvent(params).then(res => {
  270. if (res.code == 200) {
  271. this.tableData = res.data.data
  272. if (!this.groupingValue) {
  273. this.total=res.data.total
  274. }
  275. }
  276. }).catch(err => {
  277. this.tableData = []
  278. this.total=0
  279. })
  280. },
  281. //切换分组值
  282. changeGrouping(val) {
  283. if (val!='') {
  284. this.viewSelected='mergeTable'
  285. this.viewSelectedBtn='Table'
  286. } else {
  287. this.viewSelected='Table'
  288. }
  289. this.queryParams.current = 1
  290. this.groupingValue=val
  291. this.isGrouping()
  292. },
  293. // 调用分组查询的方法
  294. getGrouping() {
  295. let params = {
  296. ...this.queryParams,//分页信息
  297. searchQuery:this.$commonJS.objectToString(this.searchOption || {}),//检索条件
  298. orderDTOList:[
  299. {
  300. orderBy:this.groupingValue,
  301. orderType:this.sort&&this.sort.length>0?this.sort[0].orderType : 0
  302. }
  303. ],//排序
  304. groupBy:this.groupingValue,//分组信息
  305. }
  306. this.$api.groupEvent(params).then(res => {
  307. if (res.code == 200) {
  308. this.commonData=res.data.data.values
  309. this.total=res.data.total
  310. }
  311. }).catch(err => {
  312. this.commonData = []
  313. this.total=0
  314. })
  315. },
  316. //切换视图
  317. onChange2(type) {
  318. this.viewSelected = type
  319. this.viewSelectedBtn = type
  320. this.groupingValue=''
  321. this.queryParams.current=1
  322. this.getList()
  323. },
  324. //新增事件的选项(1是添加单个事件,2是批量添加)
  325. handleCommand(e) {
  326. switch(e){
  327. case '1'://添加单个事件
  328. var form = {
  329. scenarioId : this.scenarioId
  330. }
  331. this.$refs.addEvent.open(form, e)
  332. break;
  333. case '3'://显示栏位管理
  334. this.$refs.field.open(this.columnList)
  335. break;
  336. }
  337. },
  338. //获取排序字段// 子组件table排序
  339. handleSort({ column, prop, order, str }) {
  340. //如需要多个字段排序,则不需要清空
  341. var params = {
  342. sort:this.sort,
  343. column,
  344. prop,
  345. order,
  346. }
  347. this.sort = this.$commonJS.getSortData(params)
  348. this.queryParams.current = 1
  349. //1表示展开行2表示基础表格
  350. if (str == '1') {
  351. this.getGrouping()
  352. } else {//table排序
  353. this.getList()
  354. }
  355. },
  356. // 区分是否为分组
  357. isGrouping() {
  358. if (this.groupingValue != '') {//分组
  359. this.getGrouping()
  360. } else {//不分组
  361. this.getList()
  362. }
  363. },
  364. //表格操作列(option为操作类型,row为当前行数据,type为报告类型,单件事件弹窗为1)
  365. handleOption({ option, row, type,isLast }) {
  366. switch (option) {
  367. case '0'://新增专利数据库
  368. break;
  369. case 'addReport'://新增报告
  370. break;
  371. case '10'://删除
  372. this.eventDelete(row,isLast)
  373. break;
  374. case 'cancel'://取消关联
  375. break;
  376. case 'edit'://编辑事件,打开单件事件弹窗,1代表单个事件弹窗
  377. this.$refs.addEvent.open(row, 1)
  378. break;
  379. }
  380. },
  381. // 删除事件
  382. eventDelete(row,isLast) {
  383. this.eventDeletes([row.id],isLast)
  384. },
  385. // 批量删除事件
  386. eventDeletes(ids,isLast) {
  387. this.$confirm('此操作将删除该事件, 是否继续?', '提示', {
  388. confirmButtonText: '确定',
  389. cancelButtonText: '取消',
  390. type: 'warning'
  391. }).then(() => {
  392. this.$api.deleteEvent(ids).then(res => {
  393. if (res.code == 200) {
  394. if(isLast){
  395. this.isGrouping()
  396. } else {
  397. this.getList()
  398. }
  399. this.handleMessage = '删除成功'
  400. this.clearMessage()
  401. this.$message.success('删除成功!');
  402. }
  403. })
  404. }).catch(() => {
  405. this.$message.info('已取消删除');
  406. });
  407. },
  408. },
  409. };
  410. </script>
  411. <style lang="scss" scoped></style>