index.vue 9.9 KB

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