index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div class="airportInfo scroll-y">
  3. <div class="wrap">
  4. <Minheader
  5. :is-auth="true"
  6. :is-statuser="true"
  7. powerData="new_node_button"
  8. @addForm="addForm"
  9. >
  10. <template #header>
  11. <div class="status flex-wrap">
  12. <div class="manageTitle">节点信息维护</div>
  13. </div>
  14. </template></Minheader
  15. >
  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.nodeName"
  30. @resetForm="resetForm"
  31. @delRest="delRest"
  32. @submitForm="submitForm"
  33. @delRemove="delRemove"
  34. >
  35. <div class="diacont">
  36. <el-form :model="tableForm" :rules="formRules" ref="deployNodeForm">
  37. <el-row :gutter="24">
  38. <el-col>
  39. <el-form-item
  40. label="节点名称"
  41. size="default"
  42. prop="nodeName"
  43. :rules="formRules.isNotNull"
  44. >
  45. <el-input
  46. v-model="tableForm.nodeName"
  47. placeholder="请输入名称"
  48. />
  49. </el-form-item>
  50. </el-col>
  51. <el-col>
  52. <el-form-item
  53. label="节点编码"
  54. size="default"
  55. prop="nodeCode"
  56. :rules="formRules.isNotNull"
  57. >
  58. <el-input
  59. v-model="tableForm.nodeCode"
  60. placeholder="请输入航站名称"
  61. />
  62. </el-form-item>
  63. </el-col>
  64. <el-col>
  65. <el-form-item label="备注" size="default">
  66. <el-input
  67. type="textarea"
  68. v-model="tableForm.nodeDescribe"
  69. placeholder="请输入备注"
  70. />
  71. </el-form-item>
  72. </el-col>
  73. </el-row>
  74. </el-form>
  75. </div>
  76. </Dialog>
  77. </div>
  78. </div>
  79. </template>
  80. <script setup lang="ts">
  81. import DataTable from "@/components/tableTemp/index.vue";
  82. import Minheader from "@/components/minheader/index.vue";
  83. import Dialog from "@/components/dialog/index.vue";
  84. import { Query, GeneralDataReception } from "@/api/webApi";
  85. import { ElMessage } from "element-plus";
  86. const formRules = useElement().formRules;
  87. const page = ref<number>(0); //分页参数
  88. const dataContent = ref<object>({});
  89. const noMore = ref<Boolean>(false);
  90. const rowTitle = ref<String>("");
  91. const tableCols = ref([]); //表头数据
  92. const serviceId = ref<String>("");
  93. const tableObj = ref({}); //增删改数据缓存
  94. const flag = ref<Boolean>(false); //弹窗开关
  95. const type = ref<String>(""); //判断是否删除
  96. const msgTitle = ref<String>("新增节点信息维护"); //弹窗标题
  97. const tableColsCopys = reactive<Object>({}); //弹窗
  98. const tableForm = reactive({
  99. nodeID: "",
  100. nodeName: "",
  101. nodeCode: "",
  102. nodeDescribe: "",
  103. event: "",
  104. }); //弹窗内容
  105. //列表
  106. const tableData = ref([]);
  107. //表头
  108. const state = reactive({
  109. list: [
  110. { label: "名称", key: "name" },
  111. { label: "编码", key: "china" },
  112. { label: "描述", key: "englin" },
  113. { label: "排序", key: "two" },
  114. ],
  115. listLoading: true,
  116. });
  117. const tableBtnGroup = ref([
  118. {
  119. name: "编辑",
  120. className: "editBtn",
  121. param: 2,
  122. is: "node_editing_button",
  123. },
  124. {
  125. name: "删除",
  126. className: "delBtn",
  127. param: 3,
  128. is: "node_deletion_button",
  129. },
  130. ]);
  131. //新增
  132. const addForm = () => {
  133. msgTitle.value = "新增节点信息维护";
  134. flag.value = true;
  135. type.value = "";
  136. tableForm.event = 1;
  137. };
  138. //取消
  139. const resetForm = () => {
  140. deployNodeForm.value?.resetFields()
  141. flag.value = false;
  142. // tableForm.nodeID = "";
  143. // tableForm.nodeName = "";
  144. // tableForm.nodeCode = "";
  145. // tableForm.nodeDescribe = "";
  146. };
  147. //编辑
  148. const editDialog = (data) => {
  149. msgTitle.value = "编辑节点信息维护";
  150. flag.value = true;
  151. type.value = "";
  152. tableForm.name = data.name;
  153. tableForm.china = data.china;
  154. tableForm.englin = data.englin;
  155. };
  156. //删除
  157. const eleDialog = () => {
  158. msgTitle.value = "删除节点信息维护";
  159. flag.value = true;
  160. type.value = "del";
  161. };
  162. const delRemove = () => {
  163. tableForm.event = 3;
  164. generalDataReception(tableForm);
  165. };
  166. //删除
  167. const delRest = () => {
  168. flag.value = false;
  169. };
  170. //编辑-删除
  171. const btnClick = (row, index, param) => {
  172. if (param === 2) {
  173. msgTitle.value = "编辑节点信息维护";
  174. flag.value = true;
  175. type.value = "";
  176. tableForm.event = 2;
  177. tableForm.nodeID = index.nodeID;
  178. tableForm.nodeName = index.nodeName;
  179. tableForm.nodeCode = index.nodeCode;
  180. tableForm.nodeDescribe = index.nodeDescribe;
  181. } else if (param === 3) {
  182. msgTitle.value = "删除节点信息维护";
  183. flag.value = true;
  184. type.value = "del";
  185. tableForm.event = 3;
  186. tableForm.nodeID = index.nodeID;
  187. tableForm.nodeName = index.nodeName;
  188. tableForm.nodeCode = index.nodeCode;
  189. tableForm.nodeDescribe = index.nodeDescribe;
  190. } else if (param === 4) {
  191. }
  192. };
  193. //获取表格数据
  194. const getQuery = async () => {
  195. try {
  196. const { code, returnData } = await Query({
  197. id: DATACONTENT_ID.deployNodeId,
  198. needPage: ++page.value,
  199. dataContent: Object.values(dataContent.value),
  200. });
  201. if (code === "0") {
  202. if (returnData.listValues.length === 0) {
  203. page.value--;
  204. noMore.value = true;
  205. }
  206. const titleColumn = returnData.columnSet.find(
  207. (item) => item.needShow === 1
  208. );
  209. if (titleColumn) {
  210. rowTitle.value = titleColumn.columnName;
  211. }
  212. tableData.value.push(...returnData.listValues);
  213. tableCols.value = returnData.columnSet;
  214. tableCols.value.forEach((element) => {
  215. element.label = element.columnLabel;
  216. element.key = element.columnName;
  217. // if (element.columnName === "queryTemplate") {
  218. // element.width = "300px";
  219. // }
  220. });
  221. serviceId.value = returnData.submitID;
  222. } else {
  223. page.value--;
  224. }
  225. } catch (error) {
  226. page.value--;
  227. }
  228. };
  229. //确认提交
  230. const deployNodeForm: any = ref(null);
  231. const submitForm = () => {
  232. deployNodeForm.value.validate((valid: any) => {
  233. if (valid) {
  234. generalDataReception(tableForm);
  235. } else {
  236. return false;
  237. }
  238. });
  239. };
  240. const resetTable = () => {
  241. page.value = 0;
  242. noMore.value = false;
  243. tableData.value = [];
  244. };
  245. //新增-编辑-删除
  246. const generalDataReception = async (data) => {
  247. try {
  248. data = {
  249. ...data,
  250. };
  251. const { code } = await GeneralDataReception({
  252. serviceId: serviceId.value,
  253. dataContent: JSON.stringify(data),
  254. });
  255. if (code == 0) {
  256. ElMessage.success(`操作成功`);
  257. // this.$message.success("操作成功");
  258. resetTable();
  259. getQuery();
  260. resetForm();
  261. flag.value = false;
  262. // rmFlag.value = false;
  263. tableObj.value = {};
  264. // this.$router.go(0);
  265. } else {
  266. ElMessage.error(`操作失败`);
  267. // this.$message.error("操作失败");
  268. // this.flag = false;
  269. // this.rmFlag = false;
  270. tableObj.value = {};
  271. resetForm();
  272. }
  273. } catch (error) {
  274. flag.value = false;
  275. // rmFlag.value = false;
  276. tableObj.value = {};
  277. resetForm();
  278. }
  279. };
  280. getQuery();
  281. </script>
  282. <style lang="scss" scoped>
  283. ::v-deep .el-form-item__label {
  284. width: 80px;
  285. }
  286. </style>