index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <!--消息模板-->
  2. <template>
  3. <div class="app-container messageTemplate">
  4. <div class="page-container messageTemplatePage" v-if="pageType == 1">
  5. <div class="page-form-title-box">
  6. <el-form :model="queryParams" class="form-box" ref="queryForm"
  7. :inline="true" style="width:100%;">
  8. <el-form-item label="" prop="templateName">
  9. <el-input
  10. maxLength="30"
  11. v-model="queryParams.templateName"
  12. placeholder="请输入名称"
  13. clearable
  14. style="width: 200px"
  15. />
  16. </el-form-item>
  17. <el-form-item label="" prop="alarmType">
  18. <el-select v-model="queryParams.alarmType" clearable placeholder="请选择方式" style="width: 200px">
  19. <el-option
  20. v-for="dict in typeList"
  21. :key="dict.id"
  22. :label="dict.name"
  23. :value="dict.id"
  24. />
  25. </el-select>
  26. </el-form-item>
  27. <p class="page-inquire-common-style-button" @click="handleQuery">查询</p>
  28. <p class="page-reset-common-style-button" @click="resetQuery">重置</p>
  29. <p class="page-submit-common-style-button"
  30. style="float: right;"
  31. @click="tableButton(1)"
  32. v-hasPermiRouter="['iot:alertTemplate:add']"
  33. >新增</p>
  34. </el-form>
  35. </div>
  36. <div class="page-content-box">
  37. <el-table class="table-box" v-loading="loading" border :data="dataList">
  38. <el-table-column label="模板名称" align="left" width="200" prop="templateName" />
  39. <el-table-column label="方式" align="left" prop="alarmType" width="100" show-overflow-tooltip>
  40. <template slot-scope="scope">
  41. <p v-for="(item,index) in typeList" :key="index" v-show="item.id == scope.row.alarmType">{{item.name}}</p>
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="类型" align="left" prop="category" width="160" show-overflow-tooltip>
  45. <template slot-scope="scope">
  46. {{scope.row.alarmType==1&&scope.row.category==1?'钉钉消息':(
  47. scope.row.alarmType==1&&scope.row.category==2?'钉钉群消息':(
  48. scope.row.alarmType==2?'企业微信':(
  49. scope.row.alarmType==3?'--':(
  50. scope.row.alarmType==4&&scope.row.category==1?'专业设备':(
  51. scope.row.alarmType==4&&scope.row.category==2?'云语音':(
  52. scope.row.alarmType==5&&scope.row.category==1?'专业设备':(
  53. scope.row.alarmType==5&&scope.row.category==2?'云短信':'')))))))
  54. }}
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="内容" align="left" prop="content" show-overflow-tooltip/>
  58. <el-table-column label="状态" align="left" prop="state" width="100" show-overflow-tooltip>
  59. <template slot-scope="scope">
  60. <el-switch
  61. @click.native="tableButton(6,scope.row)"
  62. class="switch captcha-img"
  63. :active-value="true"
  64. :inactive-value="false"
  65. active-color="#0183FA"
  66. inactive-color="#999"
  67. v-model="scope.row.state"
  68. active-text="启用"
  69. inactive-text="停用"
  70. disabled
  71. ></el-switch>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="创建时间" align="left" prop="createTime" width="200" show-overflow-tooltip>
  75. <template slot-scope="scope">
  76. <span>{{ parseTime(scope.row.createTime,"{y}-{m}-{d} {h}:{i}") }}</span>
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="240" v-if="tableButtonType">
  80. <template slot-scope="scope">
  81. <div class="table-button-box">
  82. <p class="table-button-null"></p>
  83. <p class="table-button-p"
  84. @click="tableButton(2,scope.row)"
  85. v-hasPermiRouter="['iot:alertTemplate:detail']"
  86. >详情</p>
  87. <p class="table-button-p"
  88. @click="tableButton(3,scope.row)"
  89. v-hasPermiRouter="['iot:alertTemplate:edit']"
  90. >编辑</p>
  91. <p class="table-button-p"
  92. @click="tableButton(4,scope.row)"
  93. v-hasPermiRouter="['iot:alertTemplate:perms']"
  94. >调试</p>
  95. <p class="table-button-p"
  96. @click="tableButton(5,scope.row)"
  97. v-hasPermiRouter="['iot:alertTemplate:del']"
  98. >删除</p>
  99. <p class="table-button-null"></p>
  100. </div>
  101. </template>
  102. </el-table-column>
  103. </el-table>
  104. <pagination :page-sizes="[20, 30, 40, 50]"
  105. v-show="total>0"
  106. :total="total"
  107. :page.sync="queryParams.page"
  108. :limit.sync="queryParams.pageSize"
  109. @pagination="getList"
  110. />
  111. </div>
  112. </div>
  113. <addPage :propsData="propsData" v-if="pageType == 2"></addPage>
  114. </div>
  115. </template>
  116. <script>
  117. import { iotAlarmTemplateList,iotAlarmTemplateAdd,iotAlarmTemplateUpdate,iotAlarmSendCheck,iotAlarmTemplateDelete,iotAlarmTemplateChangeState } from "@/api/iotDevice/index";
  118. import addPage from "./addPage.vue";
  119. export default {
  120. name: 'index',
  121. components: {
  122. addPage
  123. },
  124. data(){
  125. return{
  126. tableButtonType:this.hasPermiDom(['iot:alertTemplate:detail','iot:alertTemplate:edit','iot:alertTemplate:perms','iot:alertTemplate:del',]),
  127. pageType:1,
  128. loading:false,
  129. typeList:[
  130. {name:"钉钉",id:1,},
  131. {name:"微信",id:2,},
  132. {name:"邮件",id:3,},
  133. {name:"电话",id:4,},
  134. {name:"短信",id:5,},
  135. ],
  136. queryParams:{
  137. page:1,
  138. pageSize:20,
  139. templateName:"",
  140. jobGroup:null,
  141. alarmType:null,
  142. },
  143. dataList:[],
  144. total:0,
  145. propsData:{},
  146. }
  147. },
  148. created(){
  149. },
  150. mounted(){
  151. this.getList();
  152. },
  153. methods:{
  154. handleQuery(){
  155. this.$set(this.queryParams,'page',1);
  156. this.getList();
  157. },
  158. resetQuery(){
  159. this.$set(this,'queryParams',{
  160. page:1,
  161. pageSize:20,
  162. templateName:"",
  163. alarmType:null,
  164. });
  165. this.getList();
  166. },
  167. dialogFormReset(){
  168. this.$set(this,'dialogForm',{
  169. });
  170. },
  171. //获取数据列表
  172. getList(){
  173. this.$set(this,'loading',true);
  174. iotAlarmTemplateList(this.queryParams).then(response => {
  175. this.$set(this,'loading',false);
  176. this.$set(this,'dataList',response.data.records);
  177. this.$set(this,'total',response.data.total);
  178. });
  179. },
  180. tableButton(type,row){
  181. let self = this;
  182. if(type == 1){
  183. this.$set(this,'pageType',2);
  184. this.$set(this,'propsData',{});
  185. }else if(type == 2){
  186. this.$set(this,'pageType',2);
  187. let obj = JSON.parse(JSON.stringify(row))
  188. obj.showType = true;
  189. this.$set(this,'propsData',obj);
  190. }else if(type == 3){
  191. this.$set(this,'pageType',2);
  192. let obj = JSON.parse(JSON.stringify(row))
  193. obj.showType = false;
  194. this.$set(this,'propsData',obj);
  195. }else if(type == 4){
  196. //调试
  197. this.$confirm('是否确认发送调试信息?', "警告", {
  198. confirmButtonText: "确定",
  199. cancelButtonText: "取消",
  200. type: "warning"
  201. }).then(function() {
  202. }).then(() => {
  203. iotAlarmSendCheck({templateId:row.templateId}).then(response => {
  204. self.msgSuccess(response.message)
  205. });
  206. }).catch(() => {});
  207. }else if(type == 5){
  208. this.$confirm('是否确认删除?', "警告", {
  209. confirmButtonText: "确定",
  210. cancelButtonText: "取消",
  211. type: "warning"
  212. }).then(function() {
  213. }).then(() => {
  214. iotAlarmTemplateDelete({templateId:row.templateId}).then(response => {
  215. self.msgSuccess(response.message)
  216. self.getList();
  217. });
  218. }).catch(() => {});
  219. }else if(type == 6){
  220. let text = row.state ? "停用" : "启用";
  221. this.$confirm('是否确认' + text + '?', "警告", {
  222. confirmButtonText: "确定",
  223. cancelButtonText: "取消",
  224. type: "warning"
  225. }).then(function() {
  226. }).then(() => {
  227. iotAlarmTemplateChangeState({templateId:row.templateId,state:!row.state,}).then(response => {
  228. self.msgSuccess(response.message)
  229. self.getList();
  230. });
  231. }).catch(() => {});
  232. }else if(type == 7){
  233. this.$set(this,'pageType',1);
  234. this.getList();
  235. }
  236. },
  237. },
  238. }
  239. </script>
  240. <style scoped lang="scss">
  241. .messageTemplate{
  242. .messageTemplatePage{
  243. }
  244. }
  245. </style>
  246. <style lang="scss">
  247. .messageTemplate{
  248. .messageTemplatePage{
  249. .switch .el-switch__label {
  250. position: absolute;
  251. display: none;
  252. color: #fff !important;
  253. }
  254. .switch .el-switch__label--right {
  255. z-index: 1;
  256. }
  257. .switch .el-switch__label--right span{
  258. margin-left: 10px;
  259. }
  260. .switch .el-switch__label--left {
  261. z-index: 1;
  262. }
  263. .switch .el-switch__label--left span{
  264. margin-left: 24px;
  265. }
  266. .switch .el-switch__label.is-active {
  267. display: block;
  268. }
  269. .switch.el-switch .el-switch__core,
  270. .el-switch .el-switch__label {
  271. width: 64px !important;
  272. margin: 0;
  273. }
  274. }
  275. }
  276. </style>