setting.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <el-card shadow="never" class="page">
  3. <div class="system-user-search">
  4. <el-form :model="tableData.param" ref="queryRef" inline @keyup.enter.native="dataList">
  5. <el-form-item label="配置名称" prop="keyWord">
  6. <el-input v-model="tableData.param.keyWord" placeholder="请输入配置名称" clearable style="width: 240px" />
  7. </el-form-item>
  8. <el-form-item>
  9. <el-button type="primary" class="ml10" @click="dataList">
  10. <el-icon>
  11. <ele-Search />
  12. </el-icon>
  13. 查询
  14. </el-button>
  15. <el-button @click="resetQuery(queryRef)">
  16. <el-icon>
  17. <ele-Refresh />
  18. </el-icon>
  19. 重置
  20. </el-button>
  21. <el-button type="primary" class="ml10" @click="onOpenAdd">
  22. <el-icon>
  23. <ele-FolderAdd />
  24. </el-icon>
  25. 新增通知
  26. </el-button>
  27. </el-form-item>
  28. </el-form>
  29. </div>
  30. <div class="flex1">
  31. <el-row>
  32. <el-col :span="8" v-for="(item, index) in tableData.data" :key="index">
  33. <div class="grid-content card">
  34. <div class="ant-card">
  35. <div class="ant-card-body">
  36. <div class="pro-table-card-item">
  37. <div class="card-item-avatar">
  38. <img width="88" height="88" :src="'/imgs/notice/' + tableData.param.sendGateway + '.svg'" alt="" />
  39. </div>
  40. <div class="card-item-body">
  41. <div class="card-item-header" style="width: 100%;">
  42. <div class="ellipsis">
  43. <div class="ellipsis card-item-header-name" style="width: 100%; height: 45px">{{ item.title }}</div>
  44. <div class="card-item-header-name" style="display: none"></div>
  45. </div>
  46. </div>
  47. <div class="card-item-content">
  48. 通知方式:<el-tag>{{ item.types == 1 ? '即时发送' : '预约发送' }}</el-tag>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="card-tools">
  55. <div class="card-button" @click="onOpenEdit(item)">
  56. <el-button type="primary" class="ml10" text bg>
  57. <el-icon>
  58. <ele-Edit />
  59. </el-icon>
  60. 修改
  61. </el-button>
  62. </div>
  63. <div class="card-button" @click="onOpenEditTem(item)">
  64. <el-button type="primary" text bg>
  65. <el-icon>
  66. <ele-Wallet />
  67. </el-icon>
  68. 模板配置
  69. </el-button>
  70. </div>
  71. <div class="card-button" @click="onRowDel(item)">
  72. <el-button type="danger" text bg>
  73. <el-icon>
  74. <ele-Delete />
  75. </el-icon>
  76. 删除
  77. </el-button>
  78. </div>
  79. </div>
  80. </div>
  81. </el-col>
  82. </el-row>
  83. </div>
  84. <div style="text-align: center;padding: 28px;" v-if="(tableData.total == 0)">暂无数据</div>
  85. <pagination v-show="tableData.total > 0" :total="tableData.total" v-model:page="tableData.param.pageNum" v-model:limit="tableData.param.pageSize" @pagination="dataList" />
  86. <EditDic ref="editDicRef" @dataList="dataList" />
  87. <EditTemDic ref="temeditDicRef" @dataList="dataList" />
  88. </el-card>
  89. </template>
  90. <script lang="ts">
  91. import { toRefs, reactive, onMounted, ref, getCurrentInstance, defineComponent } from 'vue';
  92. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  93. import EditDic from './component/setEdit.vue';
  94. import EditTemDic from './component/temEdit.vue';
  95. import api from '/@/api/notice';
  96. import { useRoute } from 'vue-router';
  97. // 定义接口来定义对象的类型
  98. interface TableDataRow {
  99. id: number;
  100. keyWord: string;
  101. sendGateway: string;
  102. type: string;
  103. }
  104. interface TableDataState {
  105. ids: number[];
  106. tableData: {
  107. data: Array<TableDataRow>;
  108. total: number;
  109. loading: boolean;
  110. param: {
  111. pageNum: number;
  112. pageSize: number;
  113. keyWord: string;
  114. sendGateway: string;
  115. types: string;
  116. };
  117. };
  118. }
  119. export default defineComponent({
  120. name: 'setlist',
  121. components: { EditDic, EditTemDic },
  122. setup() {
  123. const { proxy } = getCurrentInstance() as any;
  124. // const { notice_send_gateway } = proxy.useDict('notice_send_gateway');
  125. const addDicRef = ref();
  126. const editDicRef = ref();
  127. const temeditDicRef = ref();
  128. const detailRef = ref();
  129. const queryRef = ref();
  130. const route = useRoute();
  131. const state = reactive<TableDataState>({
  132. type: '',
  133. tableData: {
  134. data: [],
  135. total: 0,
  136. loading: false,
  137. param: {
  138. pageNum: 1,
  139. pageSize: 20,
  140. keyWord: '',
  141. sendGateway: '',
  142. types: '',
  143. },
  144. },
  145. });
  146. // 初始化表格数据
  147. const initTableData = () => {
  148. state.tableData.param.sendGateway = route.params.id;
  149. dataList();
  150. };
  151. const dataList = () => {
  152. state.tableData.loading = true;
  153. api.config
  154. .getList(state.tableData.param)
  155. .then((res: any) => {
  156. state.tableData.data = res.Data;
  157. state.tableData.total = res.Total;
  158. })
  159. .finally(() => (state.tableData.loading = false));
  160. };
  161. // 打开新增菜单弹窗
  162. const onOpenAdd = (row?: TableDataRow) => {
  163. editDicRef.value.openDialog(null, state.tableData.param.sendGateway);
  164. };
  165. // 打开修改模型弹窗
  166. const onOpenEdit = (row: TableDataRow) => {
  167. editDicRef.value.openDialog({ ...row }, state.tableData.param.sendGateway);
  168. };
  169. const onOpenEditTem = (row: TableDataRow) => {
  170. temeditDicRef.value.opentemDialog(row.id, state.tableData.param.sendGateway);
  171. };
  172. const onRowDel = (row?: TableDataRow) => {
  173. let msg = '你确定要删除所选数据?';
  174. let ids: number[] = [];
  175. if (row) {
  176. msg = `此操作将永久删除:“${row.title}”,是否继续?`;
  177. ids = row.id;
  178. } else {
  179. ids = state.ids;
  180. }
  181. if (ids.length === 0) {
  182. ElMessage.error('请选择要删除的数据。');
  183. return;
  184. }
  185. ElMessageBox.confirm(msg, '提示', {
  186. confirmButtonText: '确认',
  187. cancelButtonText: '取消',
  188. type: 'warning',
  189. })
  190. .then(() => {
  191. api.config.delete(ids).then(() => {
  192. ElMessage.success('删除成功');
  193. dataList();
  194. });
  195. })
  196. .catch(() => { });
  197. };
  198. // 页面加载时
  199. onMounted(() => {
  200. initTableData();
  201. });
  202. /** 重置按钮操作 */
  203. const resetQuery = (formEl: FormInstance | undefined) => {
  204. if (!formEl) return;
  205. formEl.resetFields();
  206. dataList();
  207. };
  208. const onActionStatus = (item: TableDataRow[]) => {
  209. if (item.status == 0) {
  210. alarm.common.deploy({ id: item.id }).then((res: any) => {
  211. dataList();
  212. });
  213. } else {
  214. alarm.common.undeploy({ id: item.id }).then((res: any) => {
  215. dataList();
  216. });
  217. }
  218. };
  219. return {
  220. onActionStatus,
  221. onOpenEditTem,
  222. temeditDicRef,
  223. addDicRef,
  224. editDicRef,
  225. detailRef,
  226. queryRef,
  227. onOpenAdd,
  228. onOpenEdit,
  229. onRowDel,
  230. dataList,
  231. resetQuery,
  232. ...toRefs(state),
  233. };
  234. },
  235. });
  236. </script>
  237. <style scoped>
  238. .el-col-12 {
  239. padding: 10px;
  240. }
  241. .el-button.is-text:not(.is-disabled).is-has-bg {
  242. background-color: var(--next-border-color-light);
  243. }
  244. .card {
  245. padding: 10px;
  246. }
  247. .ant-card {
  248. box-sizing: border-box;
  249. margin: 10px;
  250. width: 98%;
  251. font-size: 14px;
  252. font-variant: tabular-nums;
  253. border: 1px solid var(--next-border-color-light);
  254. line-height: 1.5;
  255. list-style: none;
  256. font-feature-settings: 'tnum';
  257. position: relative;
  258. border-radius: 2px;
  259. transition: all 0.3s;
  260. overflow: hidden;
  261. }
  262. .ant-card-body {
  263. padding: 24px;
  264. zoom: 1;
  265. overflow: hidden;
  266. }
  267. .pro-table-card-item {
  268. display: flex;
  269. }
  270. .pro-table-card-item .card-item-avatar {
  271. margin-right: 16px;
  272. }
  273. .pro-table-card-item .card-item-body {
  274. display: flex;
  275. flex-direction: column;
  276. flex-grow: 1;
  277. width: 0;
  278. }
  279. .pro-table-card-item .card-item-body .card-item-header {
  280. display: flex;
  281. width: calc(100% - 86px);
  282. margin-bottom: 12px;
  283. }
  284. .pro-table-card-item .card-item-body .card-item-content {
  285. display: flex;
  286. flex-wrap: wrap;
  287. }
  288. .pro-table-card-item .card-item-body .card-item-content>div {
  289. width: 50%;
  290. }
  291. .ellipsis {
  292. display: -webkit-box;
  293. overflow: hidden;
  294. text-align: left;
  295. text-overflow: ellipsis;
  296. word-break: break-all;
  297. }
  298. .card-item-body .card-item-header .card-item-header-name {
  299. font-weight: 700;
  300. font-size: 16px;
  301. }
  302. .card-state {
  303. position: absolute;
  304. top: 30px;
  305. right: -12px;
  306. display: flex;
  307. justify-content: center;
  308. width: 100px;
  309. padding: 2px 0;
  310. background-color: rgba(89, 149, 245, 0.15);
  311. transform: skewX(45deg);
  312. }
  313. .card-state.success {
  314. background-color: #f6ffed;
  315. }
  316. .iot-card .card-warp .card-content .card-state.error {
  317. background-color: rgba(229, 0, 18, 0.1);
  318. }
  319. .card-state .card-state-content {
  320. transform: skewX(-45deg);
  321. }
  322. .ant-badge-status-success {
  323. background-color: #52c41a;
  324. }
  325. .ant-badge-status-error {
  326. background-color: #ff4d4f;
  327. }
  328. .ant-badge-status-dot {
  329. position: relative;
  330. top: -1px;
  331. display: inline-block;
  332. width: 6px;
  333. height: 6px;
  334. vertical-align: middle;
  335. border-radius: 50%;
  336. }
  337. .card-tools {
  338. display: flex;
  339. margin-top: 2px;
  340. }
  341. .card-tools .card-button:not(:last-child) {
  342. margin-right: 8px;
  343. }
  344. .card-tools .card-button {
  345. display: flex;
  346. flex-grow: 1;
  347. }
  348. .card-tools .card-button>span,
  349. .card-tools .card-button button {
  350. width: 100%;
  351. border-radius: 0;
  352. }
  353. .ant-btn-link {
  354. border-color: transparent;
  355. background: transparent;
  356. box-shadow: none;
  357. }
  358. .ant-badge-status-text {
  359. margin-left: 8px;
  360. color: rgba(0, 0, 0, 0.85);
  361. font-size: 14px;
  362. }
  363. .ant-btn {
  364. line-height: 1.5715;
  365. position: relative;
  366. display: inline-block;
  367. font-weight: 400;
  368. white-space: nowrap;
  369. text-align: center;
  370. background-image: none;
  371. cursor: pointer;
  372. transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  373. -webkit-user-select: none;
  374. -moz-user-select: none;
  375. -ms-user-select: none;
  376. user-select: none;
  377. touch-action: manipulation;
  378. height: 32px;
  379. padding: 4px 15px;
  380. font-size: 14px;
  381. border-radius: 2px;
  382. }
  383. .ant-btn>.anticon {
  384. line-height: 1;
  385. }
  386. .ant-btn>span {
  387. display: inline-block;
  388. }
  389. .cardflex {
  390. display: flex;
  391. justify-content: space-between;
  392. }
  393. .statusname {
  394. font-size: 30px;
  395. margin-top: 10px;
  396. margin-bottom: 15px;
  397. }
  398. .comtest {
  399. margin-top: 20px;
  400. height: 30px;
  401. line-height: 30px;
  402. }
  403. </style>