index.vue 8.5 KB

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