index.vue 12 KB

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