index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div class="airportInfo scroll-y">
  3. <div class="wrap">
  4. <Minheader
  5. :is-auth="true"
  6. :is-statuser="true"
  7. :is-Search="true"
  8. @addForm="addForm"
  9. @searchForms="searchForms"
  10. @clearForm="clearForm"
  11. >
  12. <template #header>
  13. <div class="status flex-wrap">
  14. <div class="manageTitle">查询模板</div>
  15. </div>
  16. </template></Minheader
  17. >
  18. <div class="app-containers">
  19. <DataTable
  20. :btnGroupWidth="width"
  21. :tableHeader="tableCols"
  22. :tableData="tableData"
  23. :tableBtnGroup="tableBtnGroup"
  24. :tableProperty="{ rowKey: 'ID' }"
  25. @btnClick="btnClick"
  26. />
  27. </div>
  28. <Dialog
  29. :flag="flag"
  30. :type="type"
  31. :msgTitle="msgTitle"
  32. @resetForm="resetForm"
  33. @delRest="delRest"
  34. @submitForm="submitForm"
  35. @delRemove="delRemove"
  36. >
  37. </Dialog>
  38. </div>
  39. </div>
  40. </template>
  41. <script setup lang="ts">
  42. import DataTable from "@/components/tableTemp/index.vue";
  43. import Minheader from "@/components/minheader/index.vue";
  44. import Dialog from "@/components/dialog/index.vue";
  45. import { Query, GeneralDataReception } from "@/api/webApi";
  46. import { ElMessage } from "element-plus";
  47. import { el } from "element-plus/es/locale";
  48. const width = ref("200px");
  49. const router = useRouter();
  50. const dataId = ref<String>("4"); //请求id
  51. const page = ref<number>(0); //分页参数
  52. const dataContent = ref<object>({});
  53. const noMore = ref<Boolean>(false);
  54. const rowTitle = ref<String>("");
  55. const tableCols = ref([]); //表头数据
  56. const serviceId = ref<String>("");
  57. const tableObj = ref({}); //增删改数据缓存
  58. const flag = ref<Boolean>(false); //弹窗开关
  59. const type = ref<String>(""); //判断是否删除
  60. const msgTitle = ref<String>("新增查询模板"); //弹窗标题
  61. const tableColsCopys = reactive<Object>({}); //弹窗
  62. const tableOptionser = ref<Array>([]); //弹窗下拉
  63. const tableForm = reactive({
  64. queryConditionType: "",
  65. queryTemplateID: "",
  66. queryTemplateName: "",
  67. queryTemplateDescribe: "",
  68. dataSourceName: "",
  69. queryTemplate: "",
  70. serviceName: "",
  71. pageRows: "",
  72. event: "",
  73. }); //弹窗内容
  74. //列表
  75. const tableData = ref([]);
  76. const tableDatcopy = ref([]);
  77. //表头
  78. const state = reactive({
  79. list: [
  80. { label: "查询模板名称", key: "name" },
  81. { label: "查询模板协议", key: "china" },
  82. { label: "查询模板描述", key: "englin" },
  83. ],
  84. listLoading: true,
  85. });
  86. const tableBtnGroup = ref([
  87. {
  88. name: "编辑",
  89. className: "editBtn",
  90. param: 2,
  91. },
  92. {
  93. name: "列设置",
  94. className: "editBtn",
  95. param: 4,
  96. },
  97. {
  98. name: "删除",
  99. className: "delBtn",
  100. param: 3,
  101. },
  102. ]);
  103. //新增
  104. const addForm = () => {
  105. router.push({ path: "/systemSettings/queryTemplateAdd" });
  106. // msgTitle.value = "新增查询模板";
  107. // flag.value = true;
  108. // type.value = "";
  109. };
  110. //取消
  111. const resetForm = () => {
  112. flag.value = false;
  113. tableForm.name = "";
  114. tableForm.china = "";
  115. tableForm.englin = "";
  116. tableForm.two = "";
  117. tableForm.three = "";
  118. tableForm.text = "";
  119. };
  120. //编辑
  121. // const editDialog = (data) => {
  122. // msgTitle.value = "编辑航司信息维护";
  123. // flag.value = true;
  124. // type.value = "";
  125. // tableForm.name = data.name;
  126. // tableForm.china = data.china;
  127. // tableForm.englin = data.englin;
  128. // tableForm.two = data.two;
  129. // tableForm.three = data.three;
  130. // tableForm.text = data.text;
  131. // };
  132. //编辑-删除
  133. const btnClick = (row, index, param) => {
  134. if (param === 2) {
  135. router.push({
  136. path: "/systemSettings/queryTemplateEdit",
  137. query: {
  138. queryTemplateID: index.queryTemplateID,
  139. },
  140. });
  141. } else if (param === 3) {
  142. msgTitle.value = "删除查询模板";
  143. flag.value = true;
  144. type.value = "del";
  145. tableForm.event = 3;
  146. tableForm.queryConditionType = index.queryConditionType;
  147. tableForm.queryTemplateID = index.queryTemplateID;
  148. tableForm.queryTemplateName = index.queryTemplateName;
  149. tableForm.queryTemplateDescribe = index.queryTemplateDescribe;
  150. tableForm.dataSourceName = index.dataSourceName;
  151. tableForm.queryTemplate = index.queryTemplate;
  152. tableForm.serviceName = index.serviceName;
  153. tableForm.pageRows = index.pageRows;
  154. } else if (param === 4) {
  155. router.push({
  156. path: "/systemSettings/queryTemplateColumn",
  157. query: {
  158. queryTemplateID: index.queryTemplateID,
  159. },
  160. });
  161. }
  162. };
  163. //删除
  164. const eleDialog = () => {
  165. msgTitle.value = "删除查询模板";
  166. flag.value = true;
  167. type.value = "del";
  168. };
  169. const delRemove = () => {
  170. tableForm.event = 3;
  171. generalDataReception(tableForm);
  172. };
  173. //删除
  174. const delRest = () => {
  175. flag.value = false;
  176. };
  177. //获取表格数据
  178. const getQuery = async () => {
  179. try {
  180. const { code, returnData } = await Query({
  181. id: dataId.value,
  182. needPage: ++page.value,
  183. dataContent: Object.values(dataContent.value),
  184. });
  185. if (code === "0") {
  186. if (returnData.listValues.length === 0) {
  187. page.value--;
  188. noMore.value = true;
  189. }
  190. const titleColumn = returnData.columnSet.find(
  191. (item) => item.needShow === 1
  192. );
  193. if (titleColumn) {
  194. rowTitle.value = titleColumn.columnName;
  195. }
  196. tableData.value.push(...returnData.listValues);
  197. tableDatcopy.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 submitForm = () => {
  216. generalDataReception(tableForm);
  217. };
  218. const resetTable = () => {
  219. page.value = 0;
  220. noMore.value = false;
  221. tableData.value = [];
  222. };
  223. //新增-编辑-删除
  224. const generalDataReception = async (data) => {
  225. try {
  226. data = {
  227. ...data,
  228. };
  229. const { code } = await GeneralDataReception({
  230. serviceId: serviceId.value,
  231. dataContent: JSON.stringify(data),
  232. });
  233. if (code === "0") {
  234. ElMessage.success(`操作成功`);
  235. // this.$message.success("操作成功");
  236. resetTable();
  237. getQuery();
  238. resetForm();
  239. flag.value = false;
  240. // rmFlag.value = false;
  241. tableObj.value = {};
  242. // this.$router.go(0);
  243. } else {
  244. ElMessage.error(`操作失败`);
  245. // this.$message.error("操作失败");
  246. // this.flag = false;
  247. // this.rmFlag = false;
  248. tableObj.value = {};
  249. resetForm();
  250. }
  251. } catch (error) {
  252. flag.value = false;
  253. // rmFlag.value = false;
  254. tableObj.value = {};
  255. resetForm();
  256. }
  257. };
  258. //搜索
  259. const searchForms = (data) => {
  260. if (data) {
  261. tableData.value = [];
  262. tableDatcopy.value.forEach((element) => {
  263. if (element.queryTemplateID == data) {
  264. tableData.value.push(element);
  265. }
  266. });
  267. } else {
  268. tableData.value = [];
  269. tableDatcopy.value = [];
  270. page.value = 0;
  271. getQuery();
  272. }
  273. };
  274. //清除
  275. const clearForm = () => {
  276. tableData.value = [];
  277. tableDatcopy.value = [];
  278. page.value = 0;
  279. getQuery();
  280. };
  281. onMounted(() => {
  282. getQuery();
  283. });
  284. </script>
  285. <style lang="scss" scoped>
  286. ::v-deep .el-form-item__label {
  287. width: 100px;
  288. }
  289. .app-containers {
  290. height: calc(100vh - 180px);
  291. }
  292. </style>