index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. @resetForm="resetForm"
  25. @delRest="delRest"
  26. @submitForm="submitForm"
  27. @delRemove="delRemove"
  28. >
  29. <div class="diacont">
  30. <el-form :model="tableForm">
  31. <el-row :gutter="24">
  32. <el-col>
  33. <el-form-item label="公司名称" size="default">
  34. <el-input
  35. v-model="tableForm.companyName"
  36. placeholder="请输入公司名称"
  37. />
  38. </el-form-item>
  39. </el-col>
  40. <el-col>
  41. <el-form-item label="上级公司" size="default">
  42. <el-select
  43. style="width: 100%"
  44. v-model="tableForm.parentID"
  45. class="input-shadow"
  46. filterable
  47. default-first-option
  48. clearable
  49. placeholder="请选择"
  50. >
  51. <el-option
  52. v-for="item in tableOptionser"
  53. :key="item.v"
  54. :label="item.k"
  55. :value="item.v"
  56. >
  57. </el-option>
  58. </el-select>
  59. </el-form-item>
  60. </el-col>
  61. <el-col>
  62. <el-form-item label="公司描述" size="default">
  63. <el-input
  64. type="textarea"
  65. v-model="tableForm.companyDesc"
  66. placeholder="请输入公司描述"
  67. />
  68. </el-form-item>
  69. </el-col>
  70. </el-row>
  71. </el-form>
  72. </div>
  73. </Dialog>
  74. </div>
  75. </div>
  76. </template>
  77. <script setup lang="ts">
  78. import DataTable from "@/components/tableTemp/index.vue";
  79. import Minheader from "@/components/minheader/index.vue";
  80. import Dialog from "@/components/dialog/index.vue";
  81. import { Query, GeneralDataReception } from "@/api/webApi";
  82. import { ElMessage } from "element-plus";
  83. const page = ref<number>(0); //分页参数
  84. const dataContent = ref<object>({});
  85. const noMore = ref<Boolean>(false);
  86. const asShow = ref<Boolean>(false);
  87. const rowTitle = ref<String>("");
  88. const tableCols = ref([]); //表头数据
  89. const serviceId = ref<String>("");
  90. const tableObj = ref({}); //增删改数据缓存
  91. const flag = ref<Boolean>(false); //弹窗开关
  92. const type = ref<String>(""); //判断是否删除
  93. const msgTitle = ref<String>("新增机场公司维护"); //弹窗标题
  94. const tableOptionser = ref([]); //弹窗下拉
  95. const tableColsCopys = reactive([]); //弹窗
  96. const tableForm = reactive({
  97. companyName: "",
  98. parentID: "",
  99. companyDesc: "",
  100. companyID: "",
  101. event: "",
  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 tableData = ref([]);
  117. //表头
  118. const state = reactive({
  119. list: [
  120. { label: "公司名称", key: "name" },
  121. { label: "公司描述", key: "china" },
  122. { label: "上级公司", key: "englin" },
  123. ],
  124. listLoading: true,
  125. });
  126. //新增
  127. const addForm = () => {
  128. msgTitle.value = "新增机场公司维护";
  129. flag.value = true;
  130. type.value = "";
  131. tableForm.event = 1;
  132. asShow.value = false;
  133. asShow.value = true;
  134. };
  135. //取消
  136. const resetForm = () => {
  137. flag.value = false;
  138. tableForm.companyName = "";
  139. tableForm.parentID = "";
  140. tableForm.companyDesc = "";
  141. tableForm.companyID = "";
  142. };
  143. //编辑-删除
  144. const btnClick = (row, index, param) => {
  145. if (param === 2) {
  146. msgTitle.value = "编辑机场公司维护";
  147. flag.value = true;
  148. type.value = "";
  149. tableForm.event = 2;
  150. tableForm.companyName = index.companyName;
  151. tableForm.parentID = index.parentID;
  152. tableForm.companyDesc = index.companyDesc;
  153. tableForm.companyID = index.companyID;
  154. } else if (param === 3) {
  155. msgTitle.value = "删除机场公司维护";
  156. flag.value = true;
  157. type.value = "del";
  158. tableForm.event = 3;
  159. tableForm.companyName = index.companyName;
  160. tableForm.parentID = index.parentID;
  161. tableForm.companyDesc = index.companyDesc;
  162. tableForm.companyID = index.companyID;
  163. } else if (param === 4) {
  164. }
  165. };
  166. //删除
  167. const delRest = () => {
  168. flag.value = false;
  169. };
  170. //获取弹框-下拉数据
  171. const getSelectData = async (id, name) => {
  172. const { code, returnData } = await Query({
  173. id,
  174. dataContent: name ? [name] : name === null ? [null] : [],
  175. });
  176. if (code == 0) {
  177. tableOptionser.value = returnData.listValues;
  178. } else {
  179. tableOptionser.value = [];
  180. }
  181. };
  182. //获取表格数据
  183. const getQuery = async () => {
  184. try {
  185. const { code, returnData } = await Query({
  186. id: DATACONTENT_ID.airportTreeId,
  187. needPage: ++page.value,
  188. dataContent: Object.values(dataContent.value),
  189. });
  190. if (code === "0") {
  191. if (returnData.listValues.length === 0) {
  192. page.value--;
  193. noMore.value = true;
  194. }
  195. const titleColumn = returnData.columnSet.find(
  196. (item) => item.needShow === 1
  197. );
  198. if (titleColumn) {
  199. rowTitle.value = titleColumn.columnName;
  200. }
  201. tableData.value.push(...returnData.listValues);
  202. tableCols.value = returnData.columnSet;
  203. returnData.columnSet.forEach((item) => {
  204. if (item.listqueryTemplateID && item.columnName === "parentID") {
  205. getSelectData(item.listqueryTemplateID);
  206. }
  207. });
  208. tableCols.value.forEach((element) => {
  209. element.label = element.columnLabel;
  210. element.key = element.columnName;
  211. });
  212. serviceId.value = returnData.submitID;
  213. } else {
  214. page.value--;
  215. }
  216. } catch (error) {
  217. page.value--;
  218. }
  219. };
  220. const changeSelect = (data, name) => {
  221. if (tableForm[data].value === "") {
  222. tableForm[data].value = null;
  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. //确认提交
  266. const submitForm = () => {
  267. generalDataReception(tableForm);
  268. };
  269. const delRemove = () => {
  270. tableForm.event = 3;
  271. generalDataReception(tableForm);
  272. };
  273. getQuery();
  274. </script>
  275. <style lang="scss" scoped>
  276. ::v-deep .el-form-item__label {
  277. width: 100px;
  278. }
  279. </style>