datastructureTerm.vue 15 KB

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