autoRulesList.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div class="autoRulesList">
  3. <div class="tabBody">
  4. <a-tabs v-model="tabKey" @change="tabChange">
  5. <a-tab-pane key="1" tab="规则管理"></a-tab-pane>
  6. <!-- <a-tab-pane key="2" tab="运行记录" ></a-tab-pane> -->
  7. </a-tabs>
  8. </div>
  9. <div class="tableBody">
  10. <div class="opt" v-if="tabKey=='1'">
  11. <a-button type='primary' @click='createNewRule'>新建空白规则</a-button>
  12. <p class="title">已创建的自动规则</p>
  13. </div>
  14. <div class="opts" v-else>
  15. <a-input-search placeholder="请输入规则id" style="width:350px" v-model="rulesId" enter-button @search="onSearch" />
  16. </div>
  17. <div class="table">
  18. <a-table
  19. size="middle"
  20. :columns="columns"
  21. :dataSource="data"
  22. bordered
  23. id="outTable"
  24. :pagination="ipagination"
  25. :scroll="{ x: scrollX }"
  26. :loading="loading"
  27. @change="sort"
  28. style="word-break: break-all;"
  29. >
  30. <span slot="status" slot-scope="text,record">
  31. <a-spin :spinning="record.spin" size="small" >
  32. <div class="spin-content">
  33. <a-switch size="default" :checked=text @change="switchChange(text,record)"/>
  34. </div>
  35. </a-spin>
  36. <!-- <a-switch size="default" :checked=text @change="switchChange(text,record)"/> -->
  37. </span>
  38. <span slot="processMethod" slot-scope="text">
  39. {{text=='SEND'?'仅发送通知':'发送并关停组'}}
  40. </span>
  41. <span slot="options" slot-scope="text,record">
  42. <a href="javascript:;" @click="editRule(record)">编辑</a>
  43. <a-divider type="vertical" />
  44. <a-popconfirm
  45. title="确定删除该规则吗?"
  46. @confirm="deleteRule(record)"
  47. >
  48. <a href="javascript:;" >删除</a>
  49. </a-popconfirm>
  50. </span>
  51. </a-table>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import moment from 'moment';
  58. import { getAction, postAction, downFile, downFilePost } from '@/api/manage';
  59. let existColumns=[
  60. {
  61. title: '运行/暂停',
  62. dataIndex: 'status',
  63. align: 'center',
  64. width:100,
  65. key: 'status',
  66. scopedSlots: { customRender: 'status' }
  67. },
  68. {
  69. title: '规则名称',
  70. dataIndex: 'eventRuleName',
  71. align: 'center',
  72. key: 'eventRuleName',
  73. scopedSlots: { customRender: 'eventRuleName' }
  74. },
  75. {
  76. title: '应用对象',
  77. dataIndex: 'accountName',
  78. align: 'center',
  79. key: 'accountName',
  80. scopedSlots: { customRender: 'accountName' }
  81. },
  82. {
  83. title: '结果操作',
  84. dataIndex: 'processMethod',
  85. align: 'center',
  86. key: 'processMethod',
  87. scopedSlots: { customRender: 'processMethod' }
  88. },
  89. {
  90. title: '创建者',
  91. dataIndex: 'userName',
  92. align: 'center',
  93. key: 'userName',
  94. scopedSlots: { customRender: 'userName' }
  95. },
  96. {
  97. title: '操作',
  98. dataIndex: 'options',
  99. align: 'center',
  100. key: 'options',
  101. scopedSlots: { customRender: 'options' }
  102. },
  103. ]
  104. let recordsColumns=[
  105. {
  106. title: '规则名称',
  107. dataIndex: 'name',
  108. align: 'center',
  109. key: 'name',
  110. scopedSlots: { customRender: 'name' }
  111. },
  112. {
  113. title: '运行时间',
  114. dataIndex: 'time',
  115. align: 'center',
  116. key: 'time',
  117. scopedSlots: { customRender: 'time' }
  118. },
  119. {
  120. title: '运行对象',
  121. dataIndex: 'runObject',
  122. align: 'center',
  123. key: 'runObject',
  124. scopedSlots: { customRender: 'runObject' }
  125. },
  126. {
  127. title: '满足条件',
  128. dataIndex: 'meetCondition',
  129. align: 'center',
  130. key: 'meetCondition',
  131. scopedSlots: { customRender: 'meetCondition' }
  132. },
  133. {
  134. title: '运行结果',
  135. dataIndex: 'result',
  136. align: 'center',
  137. key: 'result',
  138. scopedSlots: { customRender: 'result' }
  139. },
  140. ]
  141. export default {
  142. data() {
  143. return {
  144. tabKey:"1",
  145. rulesId:undefined,
  146. data:[],
  147. columns:[...existColumns],
  148. scrollX:0,
  149. loading:false,
  150. ipagination: {
  151. current: 1,
  152. pageSize: 10,
  153. // pageSizeOptions: ['10', '20', '30'],
  154. showTotal: (total, range) => {
  155. return range[0] + "-" + range[1] + " 共" + total + "条"
  156. },
  157. showQuickJumper: true,
  158. showSizeChanger:true,
  159. pageSizeOptions: ['10', '30', '50'],
  160. total: 0,
  161. onChange: (current, pageSize) => {
  162. // 切换分页时的回调,
  163. // 当在页面定义change事件时,切记要把此处的事件清除,因为这两个事件重叠了,可能到时候会导致一些莫名的bug
  164. this.ipagination.current = current;
  165. this.ipagination.pageSize= pageSize;
  166. }
  167. },
  168. url:{
  169. OverTime:'/oa/wechatNoList/selectOverTimePage',
  170. abnormal:'/oa/wechatNoList/selectNoListPage',
  171. allData:'/oa/wechatCheckinData/queryPageList'
  172. },
  173. }
  174. },
  175. methods: {
  176. moment,
  177. onSearch(value) {
  178. console.log(value);
  179. },
  180. tabChange(key){
  181. console.log(key);
  182. if(key=='1'){
  183. this.columns=[...existColumns]
  184. }else{
  185. this.columns=[...recordsColumns]
  186. }
  187. },
  188. createNewRule(){
  189. this.$router.push('/newBlankRule')
  190. },
  191. sort(pagination, filters, sorter, { currentDataSource }){
  192. this.ipagination.current=pagination.current;
  193. this.ipagination.pageSize=pagination.pageSize;
  194. this.search()
  195. },
  196. editRule(record){
  197. console.log(record);
  198. this.$router.push(`/newBlankRule?id=${record.eventRuleId}`)
  199. },
  200. // recordsRule(record){
  201. // console.log(record);
  202. // },
  203. deleteRule(record){
  204. console.log(record);
  205. getAction('/alarm/alarmEventRule/delete',{
  206. id:record.eventRuleId
  207. }).then(res=>{
  208. console.log(res);
  209. if(res.success){
  210. this.getTableListHttp()
  211. }else{
  212. this.$message.error('删除失败')
  213. }
  214. })
  215. },
  216. switchChange(text,record){
  217. console.log(text,record);
  218. record.spin=true;
  219. let eventRuleStatus='1'
  220. if(text){
  221. eventRuleStatus='0'
  222. }else{
  223. eventRuleStatus='1';
  224. }
  225. postAction('/alarm/alarmEventRule/edit',{
  226. eventRuleId:record.eventRuleId,
  227. eventRuleStatus,
  228. }).then(res=>{
  229. console.log(res);
  230. record.spin=false;
  231. if(res.success){
  232. // this.getTableListHttp()
  233. if(text){
  234. record.status=false
  235. eventRuleStatus='0'
  236. }else{
  237. record.status=true
  238. eventRuleStatus='1';
  239. }
  240. }else{
  241. this.$message.error('修改失败')
  242. // this.getTableListHttp()
  243. }
  244. })
  245. },
  246. getTableListHttp(){
  247. this.data=[];
  248. this.loading=true;
  249. let url='/alarm/alarmEventRule/list'
  250. getAction(url,{
  251. pageNo:this.ipagination.current,
  252. pageSize:this.ipagination.pageSize
  253. }).then(res=>{
  254. console.log(res);
  255. this.loading=false;
  256. if(res.success){
  257. this.data=res.result.list.map(item=>{
  258. return {
  259. ...item,
  260. status:item.eventRuleStatus=='1'?true:false,
  261. spin:false,
  262. }
  263. })
  264. this.ipagination.total=res.result.total
  265. }
  266. })
  267. }
  268. },
  269. mounted(){
  270. this.getTableListHttp()
  271. },
  272. activated(){
  273. this.getTableListHttp()
  274. }
  275. }
  276. </script>
  277. <style lang="scss" scoped>
  278. .autoRulesList{
  279. background: white;
  280. padding: 20px;
  281. .tabBody{
  282. margin-bottom: 5px;
  283. }
  284. .tableBody{
  285. .opt{
  286. .title{
  287. margin: 15px 0;
  288. height: 57px;
  289. font-size: 16px;
  290. color: #333;
  291. line-height: 57px;
  292. background: #ffffff;
  293. padding-left: 15px;
  294. border-radius: 4px 4px 0 0;
  295. font-weight: 600;
  296. border-bottom: 1px solid #DADFE3;
  297. }
  298. }
  299. .opts{
  300. margin-bottom: 15px;
  301. }
  302. }
  303. }
  304. </style>