queryTemplateAdd.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div class="airportInfo scroll-y">
  3. <Minheader
  4. :is-statuser="true"
  5. :is-Preser="true"
  6. :is-Measure="true"
  7. @preserForm="preserForm"
  8. >
  9. <template #header>
  10. <div class="status flex-wrap">
  11. <div class="manageTitle">新增查询模板</div>
  12. </div>
  13. </template></Minheader
  14. >
  15. <div class="app-container">
  16. <el-form :model="ruleForm">
  17. <el-row :gutter="24">
  18. <el-col :span="6">
  19. <el-form-item label="查询模板名称" size="default">
  20. <el-input
  21. v-model="ruleForm.queryTemplateName"
  22. placeholder="请输入查询模板名称"
  23. />
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="6">
  27. <el-form-item label="数据源" prop="dataSourceID" size="default">
  28. <el-select
  29. v-model="ruleForm.dataSourceID"
  30. placeholder="请选择"
  31. clearable
  32. >
  33. <el-option
  34. v-for="item in dataSourceList"
  35. :key="item.dataSourceID"
  36. :label="item.dataSourceName"
  37. :value="item.dataSourceID"
  38. />
  39. </el-select>
  40. </el-form-item>
  41. </el-col>
  42. <el-col :span="6">
  43. <el-form-item label="服务名称" prop="submitID" size="default">
  44. <el-select
  45. v-model="ruleForm.submitID"
  46. placeholder="请选择"
  47. clearable
  48. >
  49. <el-option
  50. v-for="item in serviceList"
  51. :key="item.submitID"
  52. :label="item.serviceName"
  53. :value="item.submitID"
  54. />
  55. </el-select>
  56. </el-form-item>
  57. </el-col>
  58. <el-col :span="6">
  59. <el-form-item label="每页显示" prop="pageRows" size="default">
  60. <el-input
  61. v-model="ruleForm.pageRows"
  62. size="medium"
  63. placeholder="请输入每页显示行数"
  64. type="number"
  65. clearable
  66. />
  67. </el-form-item>
  68. </el-col>
  69. <el-col>
  70. <el-form-item label="查询模板描述" size="default">
  71. <el-input
  72. v-model="ruleForm.queryTemplateDescribe"
  73. placeholder="请输入查询模板描述"
  74. />
  75. </el-form-item>
  76. </el-col>
  77. <el-col>
  78. <el-form-item label="查询语句" size="default">
  79. <el-input
  80. :autosize="{ minRows: 24, maxRows: 24 }"
  81. type="textarea"
  82. v-model="ruleForm.serviceName"
  83. placeholder="请输入查询语句"
  84. />
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. </el-form>
  89. </div>
  90. </div>
  91. </template>
  92. <script setup lang="ts">
  93. import Minheader from "@/components/minheader/index.vue";
  94. import { Query, myQuery } from "@/api/webApi";
  95. import { ElMessage } from "element-plus";
  96. const router = useRouter();
  97. const asShOW = ref<boolean>(false);
  98. const dataSourceList = ref<Array>([]); //下拉
  99. const serviceList = ref<Array>([]); //下拉
  100. const ruleForm = reactive({
  101. queryTemplateName: "",
  102. queryTemplateDescribe: "",
  103. submitID: null,
  104. queryTemplate: "",
  105. pageRows: null,
  106. }); //内容
  107. //保存
  108. const preserForm = async () => {
  109. const params = {
  110. ...ruleForm,
  111. submitID: ruleForm.serviceID,
  112. };
  113. delete params.serviceID;
  114. try {
  115. const res = await Query({
  116. serviceId: SERVICE_ID.sysQueryTabId,
  117. dataContent: JSON.stringify(params),
  118. });
  119. if (Number(res.code) === 0) {
  120. ElMessage.success(`成功`);
  121. router.push({ path: "/systemSettings/queryTemplate" });
  122. // this.$message.success(res.message ?? "成功");
  123. // this.$router.push("/systemSettings/queryTemplate");
  124. } else {
  125. ElMessage.error(`失败`);
  126. // this.$message.error(res.message ?? "失败");
  127. }
  128. } catch (error) {
  129. ElMessage.error(`失败`);
  130. }
  131. // router.push({ path: "/systemSettings/queryTemplate" });
  132. };
  133. const getDataSourceList = async () => {
  134. const dataSourceLists = await getSelectOption(13);
  135. dataSourceList.value = dataSourceLists.map((item) => {
  136. item[item.setlabel] = item.k;
  137. item[item.setvalue] = item.v;
  138. return item;
  139. });
  140. };
  141. const getSelectOption = async (ID) => {
  142. try {
  143. const listValues = await myQuery(ID);
  144. return listValues;
  145. } catch (error) {
  146. // this.$message.error(error)
  147. return [];
  148. }
  149. };
  150. const queryServiceList = async (ID) => {
  151. const serviceLists = await getSelectOption(DATACONTENT_ID.sysServiceTabId);
  152. serviceList.value = serviceLists.map((item) => {
  153. item[item.setlabel] = item.k;
  154. item[item.setvalue] = item.v;
  155. return item;
  156. });
  157. };
  158. getDataSourceList();
  159. queryServiceList();
  160. </script>
  161. <style lang="scss" scoped>
  162. .airportInfo {
  163. padding: 24px;
  164. height: 100%;
  165. background: #ffffff;
  166. border-radius: 4px;
  167. }
  168. ::v-deep .el-form-item__label {
  169. width: 110px;
  170. }
  171. </style>