index.vue 9.4 KB

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