index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <div class="ruleSetList">
  3. <div class="toolbox-automate-rules-create-content_title"><h3> 新建空白模板</h3></div>
  4. <div class="tabBody">
  5. <div>
  6. <span>模板名称:</span>
  7. <a-input v-model="templateName" placeholder="模板名字" style="width:250px;margin-right:40px"/>
  8. </div>
  9. <div>
  10. <span>模板ID:</span>
  11. <a-input v-model="templateId" placeholder="模板ID" style="width:250px"/>
  12. </div>
  13. <div class="opt">
  14. <a-button type='primary' @click="search">查询</a-button>
  15. </div>
  16. </div>
  17. <div class="tableBody">
  18. <div class="opt" >
  19. <a-button type='primary' @click='createNewRule'>新建模板</a-button>
  20. </div>
  21. <div class="table">
  22. <a-table
  23. size="middle"
  24. :columns="columns"
  25. :dataSource="data"
  26. bordered
  27. id="outTable"
  28. :pagination="ipagination"
  29. :scroll="{ x: scrollX }"
  30. :loading="loading"
  31. @change="sort"
  32. style="word-break: break-all;"
  33. >
  34. <span slot="status" slot-scope="text,record">
  35. <a-spin :spinning="record.spin" size="small" >
  36. <div class="spin-content">
  37. <a-switch size="default" :checked=text @change="switchChange(text,record)"/>
  38. </div>
  39. </a-spin>
  40. <!-- <a-switch size="default" :checked=text @change="switchChange(text,record)"/> -->
  41. </span>
  42. <span slot="mediaType" slot-scope="text">
  43. {{text|handleMediaType}}
  44. </span>
  45. <span slot="processMethod" slot-scope="text">
  46. {{text=='SEND'?'仅发送通知':'发送并关停组'}}
  47. </span>
  48. <span slot="options" slot-scope="text,record">
  49. <a href="javascript:;" @click="editRule(record)">编辑</a>
  50. <a-divider type="vertical" />
  51. <a-popconfirm
  52. :title="`当前模板关联账户个数为${relationCount},确定删除吗?`"
  53. @confirm="deleteRule(record)"
  54. >
  55. <a href="javascript:;" @click.stop="showRelativeCount(record)">删除</a>
  56. </a-popconfirm>
  57. </span>
  58. </a-table>
  59. </div>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. import moment from 'moment';
  65. import { getAction, postAction, downFile, downFilePost ,deleteAction} from '@/api/manage';
  66. let existColumns=[
  67. // {
  68. // title: '运行/暂停',
  69. // dataIndex: 'status',
  70. // align: 'center',
  71. // width:100,
  72. // key: 'status',
  73. // scopedSlots: { customRender: 'status' }
  74. // },
  75. {
  76. title: '模板名称',
  77. dataIndex: 'templateName',
  78. align: 'center',
  79. key: 'templateName',
  80. scopedSlots: { customRender: 'templateName' }
  81. },
  82. {
  83. title: '模板ID',
  84. dataIndex: 'id',
  85. align: 'center',
  86. key: 'id',
  87. scopedSlots: { customRender: 'id' }
  88. },
  89. {
  90. title: '应用媒体',
  91. dataIndex: 'mediaType',
  92. align: 'center',
  93. key: 'mediaType',
  94. scopedSlots: { customRender: 'mediaType' }
  95. },
  96. // {
  97. // title: '结果操作',
  98. // dataIndex: 'processMethod',
  99. // align: 'center',
  100. // key: 'processMethod',
  101. // scopedSlots: { customRender: 'processMethod' }
  102. // },
  103. // {
  104. // title: '创建者',
  105. // dataIndex: 'createrName',
  106. // align: 'center',
  107. // key: 'createrName',
  108. // scopedSlots: { customRender: 'createrName' }
  109. // },
  110. {
  111. title: '操作',
  112. dataIndex: 'options',
  113. align: 'center',
  114. key: 'options',
  115. scopedSlots: { customRender: 'options' }
  116. },
  117. ]
  118. let recordsColumns=[
  119. {
  120. title: '模板名称',
  121. dataIndex: 'templateName',
  122. align: 'center',
  123. key: 'templateName',
  124. scopedSlots: { customRender: 'templateName' }
  125. },
  126. {
  127. title: '应用媒体',
  128. dataIndex: 'mediaType',
  129. align: 'center',
  130. key: 'mediaType',
  131. scopedSlots: { customRender: 'mediaType' }
  132. },
  133. {
  134. title: '运行对象',
  135. dataIndex: 'accountName',
  136. align: 'center',
  137. key: 'accountName',
  138. scopedSlots: { customRender: 'accountName' }
  139. },
  140. {
  141. title: '满足条件',
  142. dataIndex: 'alarmCondition',
  143. align: 'center',
  144. key: 'alarmCondition',
  145. scopedSlots: { customRender: 'alarmCondition' }
  146. },
  147. {
  148. title: '运行结果',
  149. dataIndex: 'processMethod',
  150. align: 'center',
  151. key: 'processMethod',
  152. scopedSlots: { customRender: 'processMethod' }
  153. },
  154. ]
  155. export default {
  156. data() {
  157. return {
  158. templateId:'',
  159. templateName:"",
  160. relationCount:2,
  161. tabKey:"1",
  162. rulesId:undefined,
  163. data:[],
  164. columns:[...existColumns],
  165. scrollX:0,
  166. loading:false,
  167. ipagination: {
  168. current: 1,
  169. pageSize: 10,
  170. // pageSizeOptions: ['10', '20', '30'],
  171. showTotal: (total, range) => {
  172. return range[0] + "-" + range[1] + " 共" + total + "条"
  173. },
  174. showQuickJumper: true,
  175. showSizeChanger:true,
  176. pageSizeOptions: ['10', '30', '50'],
  177. total: 0,
  178. onChange: (current, pageSize) => {
  179. // 切换分页时的回调,
  180. // 当在页面定义change事件时,切记要把此处的事件清除,因为这两个事件重叠了,可能到时候会导致一些莫名的bug
  181. this.ipagination.current = current;
  182. this.ipagination.pageSize= pageSize;
  183. }
  184. },
  185. url:{
  186. list:'/ruleTemplate/list',
  187. delete:'/ruleTemplate/delete',
  188. getRelationAccountById:'/ruleAccountTemplate/getRelationAccountById',
  189. },
  190. }
  191. },
  192. methods: {
  193. moment,
  194. onSearch(value) {
  195. console.log(value);
  196. },
  197. tabChange(key){
  198. console.log(key);
  199. let url=''
  200. if(key=='1'){
  201. this.columns=[...existColumns]
  202. url=this.url.existUrl
  203. }else{
  204. this.columns=[...recordsColumns]
  205. url=this.url.resultRecordUrl
  206. }
  207. this.getTableListHttp(url)
  208. },
  209. createNewRule(){
  210. this.$router.push('/earlyWarningRules/configRules')
  211. },
  212. sort(pagination, filters, sorter, { currentDataSource }){
  213. this.ipagination.current=pagination.current;
  214. this.ipagination.pageSize=pagination.pageSize;
  215. this.getTableListHttp(this.url.list)
  216. },
  217. editRule(record){
  218. console.log(record);
  219. this.$router.push(`/earlyWarningRules/configRules?id=${record.id}`)
  220. },
  221. // recordsRule(record){
  222. // console.log(record);
  223. // },
  224. showRelativeCount(record){
  225. getAction(this.url.getRelationAccountById,{
  226. id:record.id
  227. }).then(res=>{
  228. console.log(res)
  229. if(res.success){
  230. this.relationCount=res.result.relationCount
  231. }
  232. })
  233. },
  234. deleteRule(record){
  235. console.log(record);
  236. deleteAction(this.url.delete,{
  237. id:record.id
  238. }).then(res=>{
  239. console.log(res);
  240. if(res.success){
  241. this.getTableListHttp(this.url.list)
  242. }else{
  243. this.$message.error('删除失败')
  244. }
  245. })
  246. },
  247. search(){
  248. this.getTableListHttp(this.url.list)
  249. this.ipagination.current=1;
  250. },
  251. getTableListHttp(url){
  252. this.data=[];
  253. this.loading=true;
  254. getAction(url,{
  255. id:this.templateId,
  256. templateName:this.templateName,
  257. pageNo:this.ipagination.current,
  258. pageSize:this.ipagination.pageSize
  259. }).then(res=>{
  260. console.log(res);
  261. this.loading=false;
  262. if(res.success){
  263. this.data=res.result.records.map(item=>{
  264. return {
  265. ...item,
  266. status:item.eventRuleStatus=='1'?true:false,
  267. spin:false,
  268. }
  269. })
  270. this.ipagination.total=res.result.total
  271. }
  272. })
  273. }
  274. },
  275. mounted(){
  276. this.getTableListHttp(this.url.list)
  277. },
  278. activated(){
  279. this.getTableListHttp(this.url.list)
  280. },
  281. filters:{
  282. handleMediaType(val){
  283. switch (val) {
  284. case 2:
  285. return '快手'
  286. break;
  287. case 3:
  288. return '头条'
  289. break;
  290. case 4:
  291. return '快手内广'
  292. break;
  293. default:
  294. break;
  295. }
  296. }
  297. }
  298. }
  299. </script>
  300. <style lang="scss" scoped>
  301. .ruleSetList{
  302. background: white;
  303. padding: 20px;
  304. .toolbox-automate-rules-create-content_title {
  305. background-color: #fff;
  306. display: flex;
  307. flex-flow: row nowrap;
  308. justify-content: flex-start;
  309. align-items: center;
  310. margin-bottom: 28px;
  311. h3 {
  312. font-size: 22px;
  313. margin: 0;
  314. font-weight: 400;
  315. height: 30px;
  316. line-height: 30px;
  317. }
  318. }
  319. .tabBody{
  320. margin-bottom: 28px;
  321. display: flex;
  322. position: relative;
  323. font-size: 16px;
  324. .opt{
  325. position: absolute;
  326. right: 0;
  327. }
  328. }
  329. .tableBody{
  330. .opt{
  331. margin-bottom: 28px;
  332. .title{
  333. margin: 15px 0;
  334. height: 57px;
  335. font-size: 16px;
  336. color: #333;
  337. line-height: 57px;
  338. background: #ffffff;
  339. padding-left: 15px;
  340. border-radius: 4px 4px 0 0;
  341. font-weight: 600;
  342. border-bottom: 1px solid #DADFE3;
  343. }
  344. }
  345. .opts{
  346. margin-bottom: 28px;
  347. }
  348. .table{
  349. // margin-top: 20px;
  350. }
  351. }
  352. }
  353. </style>