index.vue 8.7 KB

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