index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <template>
  2. <div class="airportInfo scroll-y">
  3. <div class="wrap">
  4. <Minheader
  5. :is-auth="true"
  6. :is-statuser="true"
  7. powerData="equipment_addition_button"
  8. @addForm="addForm"
  9. >
  10. <template #header>
  11. <div class="status flex-wrap">
  12. <div class="manageTitle">设备维护</div>
  13. </div>
  14. </template>
  15. </Minheader>
  16. <div class="app-containers">
  17. <DataTable
  18. :tableHeader="tableCols"
  19. :tableData="tableData"
  20. :tableBtnGroup="tableBtnGroup"
  21. :tableProperty="{ rowKey: 'ID' }"
  22. @btnClick="btnClick"
  23. />
  24. </div>
  25. <Dialog
  26. :flag="flag"
  27. :type="type"
  28. :msgTitle="msgTitle"
  29. :delName="tableForm.deviceName"
  30. @resetForm="resetForm"
  31. @delRest="delRest"
  32. @submitForm="submitForm"
  33. @delRemove="delRemove"
  34. >
  35. <div class="diacont">
  36. <el-form
  37. :model="tableForm"
  38. :rules="formRules"
  39. ref="equipmentMaintenanceForm"
  40. >
  41. <el-row :gutter="24">
  42. <el-col>
  43. <el-form-item
  44. label="设备ID"
  45. size="default"
  46. prop="deviceID"
  47. :rules="formRules.isNotNull"
  48. >
  49. <el-input
  50. v-model="tableForm.deviceID"
  51. placeholder="请输入设备ID"
  52. />
  53. </el-form-item>
  54. </el-col>
  55. <el-col>
  56. <el-form-item
  57. label="设备名称"
  58. size="default"
  59. prop="deviceName"
  60. :rules="formRules.isNotNull"
  61. >
  62. <el-input
  63. v-model="tableForm.deviceName"
  64. placeholder="请输入设备名称"
  65. />
  66. </el-form-item>
  67. </el-col>
  68. <el-col>
  69. <el-form-item
  70. label="设备类型"
  71. size="default"
  72. :rules="formRules.isNotNull"
  73. prop="deviceType"
  74. >
  75. <el-input
  76. v-model="tableForm.deviceType"
  77. placeholder="请输入设备类型"
  78. />
  79. </el-form-item>
  80. </el-col>
  81. <el-col>
  82. <el-form-item
  83. label="设备位置"
  84. size="default"
  85. :rules="formRules.isNotNull"
  86. prop="location"
  87. >
  88. <el-input
  89. v-model="tableForm.location"
  90. placeholder="请输入设备位置"
  91. />
  92. </el-form-item>
  93. </el-col>
  94. <el-col>
  95. <el-form-item
  96. label="设备编码"
  97. size="default"
  98. prop="deviceCode"
  99. :rules="formRules.isNotNull"
  100. >
  101. <el-input
  102. v-model="tableForm.deviceCode"
  103. placeholder="请输入设备编码"
  104. />
  105. </el-form-item>
  106. </el-col>
  107. <el-col>
  108. <el-form-item
  109. label="IP"
  110. size="default"
  111. prop="deviceIP"
  112. :rules="formRules.isNotNull"
  113. >
  114. <el-input
  115. type="textarea"
  116. v-model="tableForm.deviceIP"
  117. placeholder="请输入IP"
  118. />
  119. </el-form-item>
  120. </el-col>
  121. <el-col>
  122. <el-form-item
  123. label="备注"
  124. :rules="formRules.isNotNull"
  125. size="default"
  126. >
  127. <el-input
  128. type="textarea"
  129. v-model="tableForm.remarks"
  130. placeholder="请输入备注"
  131. />
  132. </el-form-item>
  133. </el-col>
  134. </el-row>
  135. </el-form>
  136. </div>
  137. </Dialog>
  138. </div>
  139. </div>
  140. </template>
  141. <script setup lang="ts">
  142. import DataTable from "@/components/tableTemp/index.vue";
  143. import Minheader from "@/components/minheader/index.vue";
  144. import Dialog from "@/components/dialog/index.vue";
  145. import { Query, GeneralDataReception } from "@/api/webApi";
  146. import { ElMessage } from "element-plus";
  147. const formRules = useElement().formRules;
  148. const page = ref<number>(0); //分页参数
  149. const dataContent = ref<object>({});
  150. const noMore = ref<boolean>(false);
  151. const rowTitle = ref<string>("");
  152. const tableCols = ref<any>([]); //表头数据
  153. const serviceId = ref<any>("");
  154. const tableObj = ref({}); //增删改数据缓存
  155. const flag = ref<boolean>(false); //弹窗开关
  156. const type = ref<string>(""); //判断是否删除
  157. const msgTitle = ref<string>("新增设备维护"); //弹窗标题
  158. const tableColsCopys = reactive<Object>({}); //弹窗
  159. const conditon = ref("");
  160. const tableForm = reactive<any>({
  161. deviceID: "",
  162. deviceName: "",
  163. deviceType: "",
  164. deviceIP: "",
  165. location: "",
  166. deviceCode: "",
  167. remarks: "",
  168. event: "",
  169. }); //弹窗内容
  170. //列表
  171. const tableData = ref<any>([]);
  172. //表头
  173. const state = reactive({
  174. list: [
  175. { label: "设备名称", key: "name" },
  176. { label: "所在位置", key: "china" },
  177. { label: "设备类型", key: "englin" },
  178. { label: "设备IP", key: "two" },
  179. { label: "在离线状态", key: "three" },
  180. { label: "忙碌空闲", key: "text" },
  181. ],
  182. listLoading: true,
  183. });
  184. const tableBtnGroup = ref([
  185. {
  186. name: "编辑",
  187. className: "editBtn",
  188. param: 2,
  189. is: "device_editing_button",
  190. },
  191. {
  192. name: "删除",
  193. className: "delBtn",
  194. param: 3,
  195. is: "device_deletion_button",
  196. },
  197. ]);
  198. //新增
  199. const addForm = () => {
  200. msgTitle.value = "新增设备维护";
  201. flag.value = true;
  202. type.value = "";
  203. for (const key in tableForm) {
  204. tableForm[key] = "";
  205. }
  206. tableForm.event = 1;
  207. };
  208. //取消
  209. const resetForm = () => {
  210. equipmentMaintenanceForm.value?.resetFields();
  211. flag.value = false;
  212. // tableForm.deviceID = "";
  213. // tableForm.deviceName = "";
  214. // tableForm.deviceType = "";
  215. // tableForm.deviceIP = "";
  216. // tableForm.deviceCode = "";
  217. // tableForm.remarks = "";
  218. };
  219. //编辑
  220. const editDialog = (data) => {
  221. msgTitle.value = "编辑设备维护";
  222. flag.value = true;
  223. type.value = "";
  224. tableForm.name = data.name;
  225. tableForm.englin = data.englin;
  226. tableForm.two = data.two;
  227. };
  228. //删除
  229. const eleDialog = () => {
  230. msgTitle.value = "删除设备维护";
  231. flag.value = true;
  232. type.value = "del";
  233. };
  234. const delRemove = () => {
  235. const obj = {
  236. deviceID: tableForm.deviceID,
  237. event: 3,
  238. };
  239. generalDataReception(obj);
  240. };
  241. //删除
  242. const delRest = () => {
  243. flag.value = false;
  244. };
  245. //编辑-删除
  246. const btnClick = (row, index, param) => {
  247. if (param === 2) {
  248. msgTitle.value = "编辑设备维护";
  249. flag.value = true;
  250. type.value = "";
  251. tableForm.event = 2;
  252. tableForm.deviceID = index.deviceID;
  253. tableForm.deviceName = index.deviceName;
  254. tableForm.deviceType = index.deviceType;
  255. tableForm.location = index.location;
  256. tableForm.deviceIP = index.deviceIP;
  257. tableForm.deviceCode = index.deviceCode;
  258. tableForm.remarks = index.remarks;
  259. } else if (param === 3) {
  260. msgTitle.value = "删除设备维护";
  261. flag.value = true;
  262. type.value = "del";
  263. tableForm.event = 3;
  264. tableForm.deviceID = index.deviceID;
  265. tableForm.deviceName = index.deviceName;
  266. tableForm.deviceType = index.deviceType;
  267. tableForm.location = index.location;
  268. tableForm.deviceIP = index.deviceIP;
  269. tableForm.deviceCode = index.deviceCode;
  270. tableForm.deviceCode = index.deviceCode;
  271. } else if (param === 4) {
  272. }
  273. };
  274. const gueryRoles = async () => {
  275. const { code, returnData } = await Query({
  276. id: DATACONTENT_ID.allId,
  277. needPage: ++page.value,
  278. dataContent: Object.values(dataContent.value),
  279. });
  280. conditon.value = returnData.listValues[0].query_col_conditon;
  281. getQuery();
  282. };
  283. //获取表格数据
  284. const getQuery = async () => {
  285. try {
  286. const { code, returnData } = await Query({
  287. id: DATACONTENT_ID.equipmentNodeId,
  288. needPage: ++page.value,
  289. dataContent: Object.values(dataContent.value),
  290. });
  291. if (code === "0") {
  292. if (returnData.listValues.length === 0) {
  293. page.value--;
  294. noMore.value = true;
  295. }
  296. const titleColumn = returnData.columnSet.find(
  297. (item) => item.needShow == 1
  298. );
  299. if (titleColumn) {
  300. rowTitle.value = titleColumn.columnName;
  301. }
  302. tableData.value.push(...returnData.listValues);
  303. tableCols.value = [];
  304. if (conditon.value == null) {
  305. tableCols.value = returnData.columnSet;
  306. } else {
  307. tableCols.value = [];
  308. conditon.value.split(",").forEach((element) => {
  309. returnData.columnSet.forEach((res) => {
  310. if (element === res.columnName) {
  311. tableCols.value.push(res);
  312. }
  313. });
  314. });
  315. }
  316. tableCols.value.forEach((element) => {
  317. element.label = element.columnLabel;
  318. element.key = element.columnName;
  319. // if (element.columnName === "queryTemplate") {
  320. // element.width = "300px";
  321. // }
  322. });
  323. serviceId.value = returnData.submitID;
  324. } else {
  325. page.value--;
  326. }
  327. } catch (error) {
  328. page.value--;
  329. }
  330. };
  331. //确认提交
  332. const equipmentMaintenanceForm: any = ref(null);
  333. const submitForm = () => {
  334. equipmentMaintenanceForm.value.validate((valid: any) => {
  335. if (valid) {
  336. generalDataReception(tableForm);
  337. } else {
  338. return false;
  339. }
  340. });
  341. };
  342. const resetTable = () => {
  343. page.value = 0;
  344. noMore.value = false;
  345. tableData.value = [];
  346. };
  347. const btnAuthMap = [
  348. ,
  349. "equipment_addition_button",
  350. "device_editing_button",
  351. "device_deletion_button",
  352. ];
  353. //新增-编辑-删除
  354. const generalDataReception = async (data) => {
  355. try {
  356. const { code } = await GeneralDataReception({
  357. serviceId: serviceId.value,
  358. dataContent: JSON.stringify(data),
  359. btnAuth: btnAuthMap[data.event],
  360. });
  361. if (code == 0) {
  362. ElMessage.success(`操作成功`);
  363. // this.$message.success("操作成功");
  364. resetTable();
  365. gueryRoles();
  366. resetForm();
  367. flag.value = false;
  368. // rmFlag.value = false;
  369. tableObj.value = {};
  370. // this.$router.go(0);
  371. } else {
  372. ElMessage.error(`操作失败`);
  373. // this.$message.error("操作失败");
  374. // this.flag = false;
  375. // this.rmFlag = false;
  376. tableObj.value = {};
  377. resetForm();
  378. }
  379. } catch (error) {
  380. flag.value = false;
  381. // rmFlag.value = false;
  382. tableObj.value = {};
  383. resetForm();
  384. }
  385. };
  386. gueryRoles();
  387. </script>
  388. <style lang="scss" scoped>
  389. ::v-deep .el-form-item__label {
  390. width: 80px;
  391. }
  392. </style>