index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="page">
  3. <el-card shadow="nover">
  4. <el-row>
  5. <el-col :span="12" v-for="item in notice_send_gateway">
  6. <div class="ant-cards " v-if="item.status == 1">
  7. <div class="ant-card-body line">
  8. <div class="content">
  9. <div class="left">
  10. <img :src="'/imgs/notice/' + item.value + '.svg'" alt="dingding" style="height: 100px;width: 100px;" v-col="'image'" />
  11. <div class="context">
  12. <div class="title" v-col="'title'">{{ item.label }}</div>
  13. <div class="desc" v-col="'desc'">
  14. {{ item.remark }}
  15. </div>
  16. </div>
  17. </div>
  18. <div class="right" v-col="'handle'">
  19. <div class="ant-space ant-space-horizontal ant-space-align-center" style="gap: 8px;">
  20. <div class="ant-space-item" style="" v-auth="'setting'">
  21. <router-link :to="'/iotmanager/noticeservices/config/setting/' + item.value" class="link-type">
  22. <div class="action">
  23. <div class="btn">
  24. <img src="/imgs/notice/icon_m.png" style="height: 40px;width: 40px;" />
  25. <div>管理</div>
  26. </div>
  27. </div>
  28. </router-link>
  29. </div>
  30. <div class="ant-space-item" v-auth="'edit'">
  31. <div class="action" @click="onOpenEdit(item)">
  32. <div class="btn">
  33. <img src="/imgs/notice/icon_c.png" style="height: 40px;width: 40px;" />
  34. <div>配置</div>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </div>
  43. </el-col>
  44. </el-row>
  45. </el-card>
  46. <EditDic ref="editDicRef" @dataList="dataList" />
  47. <!--<LevelDic ref="levelDicRef" @dataList="dataList" />-->
  48. </div>
  49. </template>
  50. <script lang="ts">
  51. import { toRefs, reactive, onMounted, ref, defineComponent, getCurrentInstance } from "vue";
  52. import { ElMessageBox, ElMessage, FormInstance } from "element-plus";
  53. import EditDic from './component/edit.vue';
  54. // import LevelDic from './component/level.vue';
  55. import alarm from "/@/api/alarm";
  56. // 定义接口来定义对象的类型
  57. interface TableDataRow {
  58. id: number;
  59. name: string;
  60. key: string;
  61. createBy: string;
  62. }
  63. interface TableDataState {
  64. ids: number[];
  65. tableData: {
  66. data: Array<TableDataRow>;
  67. total: number;
  68. loading: boolean;
  69. param: {
  70. pageNum: number;
  71. pageSize: number;
  72. name: string;
  73. level: number;
  74. triggerType: number;
  75. };
  76. };
  77. }
  78. export default defineComponent({
  79. name: "setlist",
  80. components: { EditDic },
  81. setup() {
  82. const addDicRef = ref();
  83. const levelDicRef = ref();
  84. const editDicRef = ref();
  85. const detailRef = ref();
  86. const queryRef = ref();
  87. const { proxy } = getCurrentInstance() as any;
  88. const { notice_send_gateway } = proxy.useDict('notice_send_gateway');
  89. const state = reactive<TableDataState>({
  90. tableData: {
  91. data: [],
  92. total: 0,
  93. loading: false,
  94. param: {
  95. pageNum: 1,
  96. pageSize: 20,
  97. name: "",
  98. level: "",
  99. triggerType: "",
  100. },
  101. },
  102. });
  103. // 初始化表格数据
  104. const initTableData = () => {
  105. //dataList();
  106. };
  107. const dataList = () => {
  108. state.tableData.loading = true;
  109. alarm.common
  110. .getList(state.tableData.param)
  111. .then((res: any) => {
  112. state.tableData.data = res.list;
  113. state.tableData.total = res.Total;
  114. })
  115. .finally(() => (state.tableData.loading = false));
  116. };
  117. // 打开新增菜单弹窗
  118. const onOpenAdd = (row?: TableDataRow) => {
  119. editDicRef.value.openDialog();
  120. };
  121. const onOpenLevel = (row?: TableDataRow) => {
  122. levelDicRef.value.openDialog();
  123. };
  124. // 打开修改模型弹窗
  125. const onOpenEdit = (row: TableDataRow) => {
  126. editDicRef.value.openDialog({ ...row });
  127. };
  128. //打开数据记录
  129. const onOpenRecord = (row: TableDataRow) => {
  130. detailRef.value.openDialog(row);
  131. };
  132. const onRowDel = (row?: TableDataRow) => {
  133. let msg = "你确定要删除所选数据?";
  134. let ids: number[] = [];
  135. if (row) {
  136. msg = `此操作将永久删除:“${row.name}”,是否继续?`;
  137. ids = row.id;
  138. } else {
  139. ids = state.ids;
  140. }
  141. if (ids.length === 0) {
  142. ElMessage.error("请选择要删除的数据。");
  143. return;
  144. }
  145. ElMessageBox.confirm(msg, "提示", {
  146. confirmButtonText: "确认",
  147. cancelButtonText: "取消",
  148. type: "warning",
  149. })
  150. .then(() => {
  151. alarm.common.delete(ids).then(() => {
  152. ElMessage.success("删除成功");
  153. dataList();
  154. });
  155. })
  156. .catch(() => { });
  157. };
  158. // 页面加载时
  159. onMounted(() => {
  160. initTableData();
  161. });
  162. /** 重置按钮操作 */
  163. const resetQuery = (formEl: FormInstance | undefined) => {
  164. if (!formEl) return;
  165. formEl.resetFields();
  166. dataList();
  167. };
  168. const onActionStatus = (item: TableDataRow[]) => {
  169. if (item.status == 0) {
  170. alarm.common.deploy({ id: item.id }).then((res: any) => {
  171. dataList();
  172. });
  173. } else {
  174. alarm.common.undeploy({ id: item.id }).then((res: any) => {
  175. dataList();
  176. });
  177. }
  178. };
  179. return {
  180. onActionStatus,
  181. addDicRef,
  182. editDicRef,
  183. detailRef,
  184. queryRef,
  185. levelDicRef,
  186. notice_send_gateway,
  187. onOpenRecord,
  188. onOpenLevel,
  189. onOpenAdd,
  190. onOpenEdit,
  191. onRowDel,
  192. dataList,
  193. resetQuery,
  194. ...toRefs(state),
  195. };
  196. },
  197. });
  198. </script>
  199. <style>
  200. .line {
  201. border: 1px solid var(--next-border-color-light);
  202. ;
  203. }
  204. .ant-cards {
  205. box-sizing: border-box;
  206. margin: 0;
  207. padding: 0;
  208. color: rgba(0, 0, 0, 0.85);
  209. font-size: 14px;
  210. font-variant: tabular-nums;
  211. line-height: 1.5715;
  212. list-style: none;
  213. font-feature-settings: "tnum", "tnum";
  214. position: relative;
  215. border-radius: 2px;
  216. padding: 10px;
  217. }
  218. .ant-card-body {
  219. padding: 24px;
  220. }
  221. .ant-space {
  222. display: inline-flex;
  223. }
  224. .ant-space-align-center {
  225. align-items: center;
  226. }
  227. .ant-btn {
  228. line-height: 1.5715;
  229. position: relative;
  230. display: inline-block;
  231. font-weight: 400;
  232. white-space: nowrap;
  233. text-align: center;
  234. background-image: none;
  235. cursor: pointer;
  236. transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  237. -webkit-user-select: none;
  238. -moz-user-select: none;
  239. -ms-user-select: none;
  240. user-select: none;
  241. touch-action: manipulation;
  242. height: 32px;
  243. padding: 4px 15px;
  244. font-size: 14px;
  245. border-radius: 2px;
  246. }
  247. .ant-btn-link {
  248. color: #5b8fd9;
  249. border-color: transparent;
  250. background: transparent;
  251. box-shadow: none;
  252. }
  253. .context {
  254. display: flex;
  255. flex-direction: column;
  256. justify-content: center;
  257. height: 100px;
  258. margin-left: 15px;
  259. }
  260. .context .title {
  261. font-size: 24px;
  262. }
  263. .context .desc {
  264. font-size: 14px;
  265. }
  266. .content {
  267. display: flex;
  268. align-items: center;
  269. justify-content: space-between;
  270. }
  271. .content .left {
  272. display: flex;
  273. }
  274. .content .right .action {
  275. display: flex;
  276. justify-content: center;
  277. width: 100px;
  278. height: 100px;
  279. border: 1px solid #5b8fd9;
  280. }
  281. .content .right .action .btn {
  282. display: flex;
  283. flex-direction: column;
  284. align-items: center;
  285. justify-content: center;
  286. width: 100px;
  287. height: 100px;
  288. }
  289. </style>