index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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_data_structure_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. width="600px"
  27. :flag="flag"
  28. :type="type"
  29. :msgTitle="msgTitle"
  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="datastructureForm"
  40. >
  41. <el-row :gutter="24">
  42. <el-col>
  43. <el-form-item
  44. label="结构名称"
  45. size="default"
  46. prop="structureName"
  47. :rules="formRules.isNotNull"
  48. >
  49. <el-input
  50. v-model="tableForm.structureName"
  51. placeholder="请输入结构名称"
  52. />
  53. </el-form-item>
  54. </el-col>
  55. <el-col>
  56. <el-form-item label="数据格式" size="default">
  57. <el-select
  58. style="width: 100%"
  59. v-model="tableForm.datatype"
  60. class="input-shadow"
  61. filterable
  62. default-first-option
  63. clearable
  64. placeholder="请选择"
  65. >
  66. <el-option
  67. v-for="item in tableOptionser"
  68. :key="item.v ? item.v : item.planDepartureApt"
  69. :label="item.k ? item.k : item.planDepartureApt"
  70. :value="item.v ? item.v : item.planDepartureApt"
  71. >
  72. </el-option>
  73. </el-select>
  74. </el-form-item>
  75. </el-col>
  76. <el-col>
  77. <el-form-item
  78. label="事件标识"
  79. size="default"
  80. prop="eventID"
  81. :rules="formRules.isNotNull"
  82. >
  83. <el-input
  84. v-model="tableForm.eventID"
  85. placeholder="请输入事件标识"
  86. />
  87. </el-form-item>
  88. </el-col>
  89. <el-col>
  90. <el-form-item label="描述" size="default">
  91. <el-input
  92. type="textarea"
  93. v-model="tableForm.dataDescribe"
  94. placeholder="请输入备注"
  95. />
  96. </el-form-item>
  97. </el-col>
  98. </el-row>
  99. </el-form>
  100. </div>
  101. </Dialog>
  102. </div>
  103. </div>
  104. </template>
  105. <script setup lang="ts">
  106. import DataTable from "@/components/tableTemp/index.vue";
  107. import Minheader from "@/components/minheader/index.vue";
  108. import Dialog from "@/components/dialog/index.vue";
  109. import { Query, GeneralDataReception } from "@/api/webApi";
  110. import { ElMessage } from "element-plus";
  111. const formRules = useElement().formRules;
  112. const page = ref<number>(0); //分页参数
  113. const dataContent = ref<object>({});
  114. const noMore = ref<Boolean>(false);
  115. const rowTitle = ref<String>("");
  116. const tableCols = ref([]); //表头数据
  117. const serviceId = ref<String>("");
  118. const tableObj = ref({}); //增删改数据缓存
  119. const router = useRouter();
  120. const flag = ref<Boolean>(false); //弹窗开关
  121. const type = ref<String>(""); //判断是否删除
  122. const msgTitle = ref<String>("新增数据结构"); //弹窗标题
  123. const tableColsCopys = reactive<Object>({}); //弹窗\
  124. const tableOptionser = ref([]); //弹窗下拉
  125. const tableOptionCopys = ref([]); //弹窗下拉
  126. const tableForm = reactive({
  127. dataStructureID: "",
  128. structureName: "",
  129. datatype: "",
  130. eventID: "",
  131. dataDescribe: "",
  132. event: "",
  133. }); //弹窗内容
  134. //列表
  135. const tableData = ref([]);
  136. //表头
  137. const state = reactive({
  138. list: [
  139. { label: "结构名称", key: "name" },
  140. { label: "数据格式", key: "china" },
  141. { label: "事件标识", key: "englin" },
  142. { label: "描述", key: "two" },
  143. ],
  144. listLoading: true,
  145. });
  146. const tableBtnGroup = ref([
  147. {
  148. name: "编辑",
  149. className: "editBtn",
  150. param: 2,
  151. is: "data_structure_editing_button",
  152. },
  153. {
  154. name: "数据项",
  155. className: "editBtn",
  156. param: 4,
  157. is: "data_item_editing_page",
  158. },
  159. {
  160. name: "删除",
  161. className: "delBtn",
  162. param: 3,
  163. is: "data_structure_deletion_button",
  164. },
  165. ]);
  166. //新增
  167. const addForm = () => {
  168. msgTitle.value = "新增数据结构";
  169. flag.value = true;
  170. type.value = "";
  171. tableForm.event = 1;
  172. };
  173. //取消
  174. const resetForm = () => {
  175. datastructureForm.value?.resetFields()
  176. flag.value = false;
  177. // tableForm.dataStructureID = "";
  178. // tableForm.structureName = "";
  179. // tableForm.datatype = "";
  180. // tableForm.eventID = "";
  181. // tableForm.dataDescribe = "";
  182. };
  183. //编辑
  184. // const editDialog = (data) => {
  185. // msgTitle.value = "编辑航司信息维护";
  186. // flag.value = true;
  187. // type.value = "";
  188. // tableForm.name = data.name;
  189. // tableForm.china = data.china;
  190. // tableForm.englin = data.englin;
  191. // tableForm.two = data.two;
  192. // tableForm.three = data.three;
  193. // tableForm.text = data.text;
  194. // };
  195. //编辑-删除
  196. const btnClick = (row, index, param) => {
  197. if (param === 2) {
  198. msgTitle.value = "编辑数据结构";
  199. flag.value = true;
  200. type.value = "";
  201. tableForm.event = 2;
  202. tableForm.dataStructureID = index.dataStructureID;
  203. tableForm.structureName = index.structureName;
  204. tableForm.datatype = index.datatype;
  205. tableForm.eventID = index.eventID;
  206. tableForm.dataDescribe = index.dataDescribe;
  207. } else if (param === 3) {
  208. msgTitle.value = "删除数据结构";
  209. flag.value = true;
  210. type.value = "del";
  211. tableForm.event = 3;
  212. tableForm.dataStructureID = index.dataStructureID;
  213. tableForm.structureName = index.structureName;
  214. tableForm.datatype = index.datatype;
  215. tableForm.eventID = index.eventID;
  216. tableForm.dataDescribe = index.dataDescribe;
  217. } else if (param === 4) {
  218. router.push({
  219. path: "/systemSettings/datastructureTerm",
  220. query: {
  221. dataStructureID: index.dataStructureID,
  222. },
  223. });
  224. }
  225. };
  226. //删除
  227. const eleDialog = () => {
  228. msgTitle.value = "删除数据结构";
  229. flag.value = true;
  230. type.value = "del";
  231. };
  232. const delRemove = () => {
  233. tableForm.event = 3;
  234. generalDataReception(tableForm);
  235. };
  236. //删除
  237. const delRest = () => {
  238. flag.value = false;
  239. };
  240. //获取弹框-下拉数据
  241. const getSelectData = async (id, name) => {
  242. const { code, returnData } = await Query({
  243. id,
  244. dataContent: name ? [name] : name === null ? [null] : [],
  245. });
  246. if (code == 0) {
  247. tableOptionser.value = returnData.listValues;
  248. } else {
  249. tableOptionser.value = [];
  250. }
  251. };
  252. //获取表格数据
  253. const getQuery = async () => {
  254. try {
  255. const { code, returnData } = await Query({
  256. id: DATACONTENT_ID.structureTabId,
  257. needPage: ++page.value,
  258. dataContent: Object.values(dataContent.value),
  259. });
  260. if (code === "0") {
  261. if (returnData.listValues.length === 0) {
  262. page.value--;
  263. noMore.value = true;
  264. }
  265. const titleColumn = returnData.columnSet.find(
  266. (item) => item.needShow === 1
  267. );
  268. if (titleColumn) {
  269. rowTitle.value = titleColumn.columnName;
  270. }
  271. tableData.value.push(...returnData.listValues);
  272. tableCols.value = returnData.columnSet;
  273. returnData.columnSet.forEach((item) => {
  274. if (item.listqueryTemplateID && item.columnName === "datatype") {
  275. getSelectData(item.listqueryTemplateID);
  276. }
  277. });
  278. tableCols.value.forEach((element) => {
  279. element.label = element.columnLabel;
  280. element.key = element.columnName;
  281. // if (element.columnName === "queryTemplate") {
  282. // element.width = "300px";
  283. // }
  284. });
  285. serviceId.value = returnData.submitID;
  286. } else {
  287. page.value--;
  288. }
  289. } catch (error) {
  290. page.value--;
  291. }
  292. };
  293. //确认提交
  294. const datastructureForm: any = ref(null);
  295. const submitForm = () => {
  296. datastructureForm.value.validate((valid: any) => {
  297. if (valid) {
  298. generalDataReception(tableForm);
  299. } else {
  300. return false;
  301. }
  302. });
  303. };
  304. const resetTable = () => {
  305. page.value = 0;
  306. noMore.value = false;
  307. tableData.value = [];
  308. };
  309. const btnAuthMap = [, 'new_data_structure_button', 'data_structure_editing_button', 'data_structure_deletion_button']
  310. //新增-编辑-删除
  311. const generalDataReception = async (data) => {
  312. try {
  313. data = {
  314. ...data,
  315. };
  316. const { code } = await GeneralDataReception({
  317. serviceId: serviceId.value,
  318. dataContent: JSON.stringify(data),
  319. btnAuth: btnAuthMap[data.event],
  320. });
  321. if (code == 0) {
  322. ElMessage.success(`操作成功`);
  323. // this.$message.success("操作成功");
  324. resetTable();
  325. getQuery();
  326. resetForm();
  327. flag.value = false;
  328. // rmFlag.value = false;
  329. tableObj.value = {};
  330. // this.$router.go(0);
  331. } else {
  332. ElMessage.error(`操作失败`);
  333. // this.$message.error("操作失败");
  334. // this.flag = false;
  335. // this.rmFlag = false;
  336. tableObj.value = {};
  337. resetForm();
  338. }
  339. } catch (error) {
  340. flag.value = false;
  341. // rmFlag.value = false;
  342. tableObj.value = {};
  343. resetForm();
  344. }
  345. };
  346. getQuery();
  347. </script>
  348. <style lang="scss" scoped>
  349. ::v-deep .el-form-item__label {
  350. width: 90px;
  351. }
  352. </style>