datastructureTerm.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  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. width="800px"
  22. :flag="flag"
  23. :type="type"
  24. :msgTitle="msgTitle"
  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="datastructureTermForm"
  35. >
  36. <el-row :gutter="24">
  37. <el-col :span="12">
  38. <el-form-item
  39. label="数据项名称"
  40. size="default"
  41. prop="ItemName"
  42. :rules="formRules.isNotNull"
  43. >
  44. <el-input
  45. v-model="tableForm.ItemName"
  46. placeholder="请输入数据项名称"
  47. />
  48. </el-form-item>
  49. </el-col>
  50. <el-col :span="12">
  51. <el-form-item label="数据项类型" size="default">
  52. <!-- <el-input
  53. v-model="tableForm.dataType"
  54. placeholder="请输入数据项类型"
  55. /> -->
  56. <el-select
  57. style="width: 100%"
  58. v-model="tableForm.dataType"
  59. class="input-shadow"
  60. filterable
  61. default-first-option
  62. clearable
  63. placeholder="请选择"
  64. >
  65. <el-option
  66. v-for="item in tableOptionser"
  67. :key="item.v ? item.v : item.planDepartureApt"
  68. :label="item.k ? item.k : item.planDepartureApt"
  69. :value="item.v ? item.v : item.planDepartureApt"
  70. >
  71. </el-option>
  72. </el-select>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="12">
  76. <el-form-item
  77. label="输出标识符"
  78. size="default"
  79. prop="outputIdentifier"
  80. :rules="formRules.isNotNull"
  81. >
  82. <el-input
  83. v-model="tableForm.outputIdentifier"
  84. placeholder="请输入输出标识符"
  85. />
  86. </el-form-item>
  87. </el-col>
  88. <el-col :span="12">
  89. <!-- <el-form-item label="描述" size="default">
  90. <el-input v-model="tableForm.two" placeholder="请输入描述" />
  91. </el-form-item> -->
  92. </el-col>
  93. <el-col :span="8">
  94. <el-form-item
  95. label="唯一项"
  96. size="default"
  97. prop="isKey"
  98. :rules="formRules.isNotNull"
  99. >
  100. <el-select
  101. style="width: 100%"
  102. v-model="tableForm.isKey"
  103. class="input-shadow"
  104. filterable
  105. default-first-option
  106. clearable
  107. placeholder="请选择"
  108. >
  109. <el-option
  110. v-for="item in tableOptionser"
  111. :key="item.v ? item.v : item.planDepartureApt"
  112. :label="item.k ? item.k : item.planDepartureApt"
  113. :value="item.v ? item.v : item.planDepartureApt"
  114. >
  115. </el-option>
  116. </el-select>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="8">
  120. <el-form-item
  121. label="必填项"
  122. size="default"
  123. prop="isMust"
  124. :rules="formRules.isNotNull"
  125. >
  126. <el-select
  127. style="width: 100%"
  128. v-model="tableForm.isMust"
  129. class="input-shadow"
  130. filterable
  131. default-first-option
  132. clearable
  133. placeholder="请选择"
  134. >
  135. <el-option
  136. v-for="item in tableOptionser"
  137. :key="item.v ? item.v : item.planDepartureApt"
  138. :label="item.k ? item.k : item.planDepartureApt"
  139. :value="item.v ? item.v : item.planDepartureApt"
  140. >
  141. </el-option>
  142. </el-select>
  143. </el-form-item>
  144. </el-col>
  145. <el-col :span="8">
  146. <el-form-item
  147. label="多条拆分"
  148. size="default"
  149. prop="isSplite"
  150. :rules="formRules.isNotNull"
  151. >
  152. <el-select
  153. style="width: 100%"
  154. v-model="tableForm.isSplite"
  155. class="input-shadow"
  156. filterable
  157. default-first-option
  158. clearable
  159. placeholder="请选择"
  160. >
  161. <el-option
  162. v-for="item in tableOptionser"
  163. :key="item.v ? item.v : item.planDepartureApt"
  164. :label="item.k ? item.k : item.planDepartureApt"
  165. :value="item.v ? item.v : item.planDepartureApt"
  166. >
  167. </el-option>
  168. </el-select>
  169. </el-form-item>
  170. </el-col>
  171. <!-- <el-col>
  172. <el-form-item label="取值表达式" size="default">
  173. <el-input
  174. type="textarea"
  175. v-model="tableForm.text2"
  176. placeholder="请输入取值表达式"
  177. />
  178. </el-form-item>
  179. </el-col> -->
  180. <!-- <el-col>
  181. <el-form-item label="实时计算表达式" size="default">
  182. <el-input
  183. type="textarea"
  184. v-model="tableForm.text3"
  185. placeholder="请输入实时计算表达式"
  186. />
  187. </el-form-item>
  188. </el-col> -->
  189. <!-- <el-col>
  190. <el-form-item label="计算结果标识符" size="default">
  191. <el-input
  192. v-model="tableForm.text4"
  193. placeholder="请输入计算结果标识符"
  194. />
  195. </el-form-item>
  196. </el-col> -->
  197. <!-- <el-col>
  198. <el-form-item label="计算参数" size="default">
  199. <el-input
  200. v-model="tableForm.text5"
  201. placeholder="请输入计算参数"
  202. />
  203. </el-form-item>
  204. </el-col> -->
  205. <el-col :span="12">
  206. <el-form-item label="计算数据源" size="default">
  207. <el-select
  208. style="width: 100%"
  209. v-model="tableForm.dataSourceID"
  210. class="input-shadow"
  211. filterable
  212. default-first-option
  213. clearable
  214. placeholder="请选择"
  215. >
  216. <el-option
  217. v-for="item in tableOption"
  218. :key="item.v ? item.v : item.planDepartureApt"
  219. :label="item.k ? item.k : item.planDepartureApt"
  220. :value="item.v ? item.v : item.planDepartureApt"
  221. >
  222. </el-option>
  223. </el-select>
  224. </el-form-item>
  225. </el-col>
  226. </el-row>
  227. </el-form>
  228. </div>
  229. </Dialog>
  230. </div>
  231. </div>
  232. </template>
  233. <script setup lang="ts">
  234. import DataTable from "@/components/tableTemp/index.vue";
  235. import Minheader from "@/components/minheader/index.vue";
  236. import Dialog from "@/components/dialog/index.vue";
  237. import { Query, GeneralDataReception } from "@/api/webApi";
  238. import { ElMessage } from "element-plus";
  239. const formRules = useElement().formRules;
  240. const router = useRouter();
  241. const route = useRoute();
  242. const page = ref<number>(0); //分页参数
  243. const dataContent = ref<object>({});
  244. const noMore = ref<Boolean>(false);
  245. const rowTitle = ref<String>("");
  246. const tableCols = ref([]); //表头数据
  247. const serviceId = ref<String>("");
  248. const tableObj = ref({}); //增删改数据缓存
  249. const flag = ref<Boolean>(false); //弹窗开关
  250. const type = ref<String>(""); //判断是否删除
  251. const msgTitle = ref<String>("新增数据项"); //弹窗标题
  252. const tableColsCopys = reactive<Object>({}); //弹窗
  253. const tableOptionser = ref<Array>([
  254. {
  255. k: "是",
  256. v: "1",
  257. },
  258. {
  259. k: "否",
  260. v: "0",
  261. },
  262. ]); //弹窗下拉
  263. const tableOption = ref<Array>([]); //弹窗下拉
  264. const tableForm = reactive({
  265. ItemID: "",
  266. dataStructureID: route.query.dataStructureID,
  267. ItemName: "",
  268. outputIdentifier: "",
  269. dataType: "",
  270. isKey: "",
  271. isMust: "",
  272. isSplite: "",
  273. dataSourceName: "",
  274. dataSourceID: "",
  275. event: "",
  276. }); //弹窗内容
  277. //列表
  278. const tableData = ref([]);
  279. //表头
  280. const state = reactive({
  281. list: [
  282. { label: "项名称", key: "name" },
  283. { label: "输出编码", key: "china" },
  284. { label: "数据类型", key: "englin" },
  285. { label: "唯一项", key: "two" },
  286. { label: "必填项", key: "three" },
  287. { label: "拆分项", key: "text" },
  288. { label: "计算数据源", key: "text1" },
  289. ],
  290. listLoading: true,
  291. });
  292. const tableBtnGroup = ref([
  293. {
  294. name: "编辑",
  295. className: "editBtn",
  296. param: 2,
  297. },
  298. {
  299. name: "删除",
  300. className: "delBtn",
  301. param: 3,
  302. },
  303. ]);
  304. //新增
  305. const addForm = () => {
  306. msgTitle.value = "新增数据项";
  307. tableForm.event = 1;
  308. flag.value = true;
  309. type.value = "";
  310. };
  311. //取消
  312. const resetForm = () => {
  313. flag.value = false;
  314. tableForm.ItemID = "";
  315. tableForm.ItemName = "";
  316. tableForm.outputIdentifier = "";
  317. tableForm.dataType = "";
  318. tableForm.isKey = "";
  319. tableForm.isMust = "";
  320. tableForm.isSplite = "";
  321. tableForm.dataSourceName = "";
  322. };
  323. //编辑
  324. // const editDialog = (data) => {
  325. // msgTitle.value = "编辑航司信息维护";
  326. // flag.value = true;
  327. // type.value = "";
  328. // tableForm.name = data.name;
  329. // tableForm.china = data.china;
  330. // tableForm.englin = data.englin;
  331. // tableForm.two = data.two;
  332. // tableForm.three = data.three;
  333. // tableForm.text = data.text;
  334. // };
  335. //编辑-删除
  336. const btnClick = (row, index, param) => {
  337. if (param === 2) {
  338. msgTitle.value = "编辑数据项";
  339. flag.value = true;
  340. type.value = "";
  341. tableForm.event = 2;
  342. tableForm.ItemID = index.ItemID;
  343. tableForm.ItemName = index.ItemName;
  344. tableForm.outputIdentifier = index.outputIdentifier;
  345. tableForm.dataType = index.dataType;
  346. tableForm.isKey = index.isKey === "唯一" ? "1" : "0";
  347. tableForm.isMust = index.isMust === "必填" ? "1" : "0";
  348. tableForm.isSplite = index.isSplite === "拆分" ? "1" : "0";
  349. tableForm.dataSourceID = index.dataSourceID;
  350. tableForm.dataSourceName = index.dataSourceName;
  351. } else if (param === 3) {
  352. msgTitle.value = "删除数据项";
  353. flag.value = true;
  354. type.value = "del";
  355. tableForm.event = 3;
  356. tableForm.ItemID = index.ItemID;
  357. tableForm.ItemName = index.ItemName;
  358. tableForm.outputIdentifier = index.outputIdentifier;
  359. tableForm.dataType = index.dataType;
  360. tableForm.isKey = index.isKey;
  361. tableForm.isMust = index.isMust;
  362. tableForm.isSplite = index.isSplite;
  363. tableForm.dataSourceName = index.dataSourceName;
  364. } else if (param === 4) {
  365. }
  366. };
  367. //删除
  368. const eleDialog = () => {
  369. msgTitle.value = "删除数据项";
  370. flag.value = true;
  371. type.value = "del";
  372. };
  373. const delRemove = () => {
  374. tableForm.event = 3;
  375. generalDataReception(tableForm);
  376. };
  377. //删除
  378. const delRest = () => {
  379. flag.value = false;
  380. };
  381. //获取表格数据
  382. const getQuery = async () => {
  383. try {
  384. const { code, returnData } = await Query({
  385. id: DATACONTENT_ID.dataitemTabId,
  386. needPage: ++page.value,
  387. dataContent: [route.query.dataStructureID],
  388. });
  389. if (code === "0") {
  390. if (returnData.listValues.length === 0) {
  391. page.value--;
  392. noMore.value = true;
  393. }
  394. const titleColumn = returnData.columnSet.find(
  395. (item) => item.needShow === 1
  396. );
  397. if (titleColumn) {
  398. rowTitle.value = titleColumn.columnName;
  399. }
  400. tableData.value.push(...returnData.listValues);
  401. tableCols.value = returnData.columnSet;
  402. tableCols.value.forEach((element) => {
  403. element.label = element.columnLabel;
  404. element.key = element.columnName;
  405. // if (element.columnName === "queryTemplate") {
  406. // element.width = "300px";
  407. // }
  408. });
  409. serviceId.value = returnData.submitID;
  410. } else {
  411. page.value--;
  412. }
  413. } catch (error) {
  414. page.value--;
  415. }
  416. };
  417. //确认提交
  418. const datastructureTermForm: any = ref(null);
  419. const submitForm = () => {
  420. datastructureTermForm.value.validate((valid: any) => {
  421. if (valid) {
  422. generalDataReception(tableForm);
  423. } else {
  424. return false;
  425. }
  426. });
  427. };
  428. const resetTable = () => {
  429. page.value = 0;
  430. noMore.value = false;
  431. tableData.value = [];
  432. };
  433. //新增-编辑-删除
  434. const generalDataReception = async (data) => {
  435. try {
  436. let obj = {
  437. dataStructureID: route.query.dataStructureID,
  438. };
  439. data = {
  440. ...data,
  441. ...obj,
  442. };
  443. const { code } = await GeneralDataReception({
  444. serviceId: serviceId.value,
  445. dataContent: JSON.stringify(data),
  446. });
  447. if (code == 0) {
  448. ElMessage.success(`操作成功`);
  449. // this.$message.success("操作成功");
  450. resetTable();
  451. getQuery();
  452. resetForm();
  453. flag.value = false;
  454. // rmFlag.value = false;
  455. tableObj.value = {};
  456. // this.$router.go(0);
  457. } else {
  458. ElMessage.error(`操作失败`);
  459. // this.$message.error("操作失败");
  460. // this.flag = false;
  461. // this.rmFlag = false;
  462. tableObj.value = {};
  463. resetForm();
  464. }
  465. } catch (error) {
  466. flag.value = false;
  467. // rmFlag.value = false;
  468. tableObj.value = {};
  469. resetForm();
  470. }
  471. };
  472. getQuery();
  473. </script>
  474. <style lang="scss" scoped>
  475. ::v-deep .el-form-item__label {
  476. width: 110px;
  477. }
  478. .app-containers {
  479. height: calc(100vh - 180px);
  480. }
  481. </style>