index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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="getList()"
  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 = data
  177. },
  178. // 子组件新增事件成功
  179. handleSuccess(val) {
  180. this.handleMessage = val
  181. this.queryParams.current = 1
  182. this.isGrouping()
  183. this.clearMessage()
  184. },
  185. //清空信息
  186. clearMessage(){
  187. this.$nextTick(()=>{
  188. this.handleMessage = ''
  189. })
  190. },
  191. //显示视图?
  192. showViews() {
  193. this.showView = false
  194. this.$nextTick(() => {
  195. this.showView = true
  196. })
  197. },
  198. //获取table栏位及分组字段、检索字段
  199. async getColumn() {
  200. let params = ['event']
  201. await this.$api.getParamsCommon(params).then(res => {
  202. if (res.code == 200) {
  203. let conditionDTOList= JSON.parse(JSON.stringify(res.data[0].conditionDTOList))
  204. // 分组字段
  205. this.groupingOption = this.$commonJS.getField(conditionDTOList,(u)=> u.ifGroup == true,{
  206. name: 'name',
  207. value: 'value',
  208. })
  209. // 搜索字段
  210. this.searchFiled = this.$commonJS.getField(conditionDTOList,(u)=> u.ifSearch == true ,{
  211. label: 'name',
  212. value: 'value',
  213. type:'type',
  214. })
  215. //为应用场景添加选项
  216. var obj = this.searchFiled.find(item=>{return item.label == '应用场景'})
  217. if(obj){
  218. obj.options = this.scene.map(item=>{
  219. return {
  220. label:item.name,
  221. value:item.id
  222. }
  223. })
  224. }
  225. }
  226. })
  227. this.showViews()
  228. },
  229. //获取检索条件检索
  230. search(val) {
  231. let params = {}
  232. val.forEach(item => {
  233. if (item.type == 3) {
  234. params[item.value]=item.searchValue.map(itemValue => {
  235. return itemValue.value
  236. })
  237. } else {
  238. params[item.value]=item.searchValue.label
  239. }
  240. })
  241. // 返回条件对象
  242. this.searchOption=params
  243. // 调用查询接口
  244. this.queryParams.current=1
  245. this.isGrouping()
  246. },
  247. // 分页
  248. handleCurrentChange(val) {
  249. this.queryParams.current = val;
  250. this.isGrouping()
  251. },
  252. //查询事件数据
  253. getList() {
  254. let params = {
  255. ...this.queryParams,//分页信息
  256. searchQuery:this.$commonJS.objectToString(this.searchOption || {}),//检索条件
  257. orderDTOList: this.sort,//排序
  258. }
  259. this.$api.queryEvent(params).then(res => {
  260. if (res.code == 200) {
  261. this.tableData = res.data.data
  262. if (!this.groupingValue) {
  263. this.total=res.data.total
  264. }
  265. }
  266. }).catch(err => {
  267. this.tableData = []
  268. this.total=0
  269. })
  270. },
  271. //切换分组值
  272. changeGrouping(val) {
  273. if (val!='') {
  274. this.viewSelected='mergeTable'
  275. } else {
  276. this.viewSelected='Table'
  277. }
  278. this.queryParams.current = 1
  279. this.groupingValue=val
  280. this.isGrouping()
  281. },
  282. // 调用分组查询的方法
  283. getGrouping() {
  284. let params = {
  285. ...this.queryParams,//分页信息
  286. searchQuery:this.$commonJS.objectToString(this.searchOption || {}),//检索条件
  287. orderDTOList:this.sort,//排序
  288. groupBy:this.groupingValue,//分组信息
  289. }
  290. this.$api.groupEvent(params).then(res => {
  291. if (res.code == 200) {
  292. this.commonData=res.data.data.values
  293. this.total=res.data.total
  294. }
  295. }).catch(err => {
  296. this.commonData = []
  297. this.total=0
  298. })
  299. },
  300. //切换视图
  301. onChange2(type) {
  302. this.viewSelected = type
  303. this.viewSelectedBtn = type
  304. this.groupingValue=''
  305. this.queryParams.current=1
  306. this.getList()
  307. },
  308. //新增事件的选项(1是添加单个事件,2是批量添加)
  309. handleCommand(e) {
  310. switch(e){
  311. case '1'://添加单个事件
  312. var form = {
  313. scenarioId : this.scenarioId
  314. }
  315. this.$refs.addEvent.open(form, e)
  316. break;
  317. case '3'://显示栏位管理
  318. this.$refs.field.open(this.columnList)
  319. break;
  320. }
  321. },
  322. //获取排序字段// 子组件table排序
  323. handleSort({ column, prop, order, str }) {
  324. //如需要多个字段排序,则不需要清空
  325. var params = {
  326. sort:this.sort,
  327. column,
  328. prop,
  329. order,
  330. }
  331. this.sort = this.$commonJS.getSortData(params)
  332. this.queryParams.current = 1
  333. //1表示展开行2表示基础表格
  334. if (str == '1') {
  335. this.getGrouping()
  336. } else {//table排序
  337. this.getList()
  338. }
  339. },
  340. // 区分是否为分组
  341. isGrouping() {
  342. if (this.groupingValue != '') {//分组
  343. this.getGrouping()
  344. } else {//不分组
  345. this.getList()
  346. }
  347. },
  348. //表格操作列(option为操作类型,row为当前行数据,type为报告类型,单件事件弹窗为1)
  349. handleOption({ option, row, type,isLast }) {
  350. switch (option) {
  351. case '0'://新增专利数据库
  352. break;
  353. case 'addReport'://新增报告
  354. break;
  355. case '10'://删除
  356. this.eventDelete(row,isLast)
  357. break;
  358. case 'cancel'://取消关联
  359. break;
  360. case 'edit'://编辑事件,打开单件事件弹窗,1代表单个事件弹窗
  361. this.$refs.addEvent.open(row, 1)
  362. break;
  363. }
  364. },
  365. // 删除事件
  366. eventDelete(row,isLast) {
  367. this.eventDeletes([row.id],isLast)
  368. },
  369. // 批量删除事件
  370. eventDeletes(ids,isLast) {
  371. this.$confirm('此操作将删除该事件, 是否继续?', '提示', {
  372. confirmButtonText: '确定',
  373. cancelButtonText: '取消',
  374. type: 'warning'
  375. }).then(() => {
  376. this.$api.deleteEvent(ids).then(res => {
  377. if (res.code == 200) {
  378. if(isLast){
  379. this.isGrouping()
  380. } else {
  381. this.getList()
  382. }
  383. this.handleMessage = '删除成功'
  384. this.clearMessage()
  385. this.$message.success('删除成功!');
  386. }
  387. })
  388. }).catch(() => {
  389. this.$message.info('已取消删除');
  390. });
  391. },
  392. },
  393. };
  394. </script>
  395. <style lang="scss" scoped></style>