index.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <div class="airportInfo scroll-y">
  3. <div class="wrap">
  4. <Minheader
  5. :is-auth="true"
  6. :is-statuser="true"
  7. powerData="position_addition_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. :flag="flag"
  27. :type="type"
  28. :msgTitle="msgTitle"
  29. :delName="tableForm.positionDescribe"
  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="positionSettingForm"
  40. >
  41. <el-row :gutter="24">
  42. <!-- <el-col>
  43. <el-form-item
  44. label="区域ID"
  45. size="default"
  46. prop="terminalID"
  47. :rules="formRules.isNotNull"
  48. >
  49. <el-input
  50. disabled
  51. v-model="tableForm.terminalID"
  52. placeholder="请输入区域ID"
  53. />
  54. </el-form-item>
  55. </el-col> -->
  56. <el-col>
  57. <el-form-item
  58. label="区域名称"
  59. size="default"
  60. prop="terminalName"
  61. :rules="formRules.isNotNull"
  62. >
  63. <el-input
  64. disabled
  65. v-model="tableForm.terminalName"
  66. placeholder="请输入区域名称"
  67. />
  68. </el-form-item>
  69. </el-col>
  70. <el-col>
  71. <el-form-item
  72. label="位置名称"
  73. size="default"
  74. prop="positionDescribe"
  75. :rules="formRules.isNotNull"
  76. >
  77. <el-input
  78. v-model="tableForm.positionDescribe"
  79. placeholder="请输入位置名称"
  80. />
  81. </el-form-item>
  82. </el-col>
  83. <!-- <el-col>
  84. <el-form-item
  85. label="位置序号"
  86. size="default"
  87. prop="positionSN"
  88. :rules="formRules.isNotNull"
  89. >
  90. <el-input
  91. v-model="tableForm.positionSN"
  92. placeholder="请输入位置序号"
  93. />
  94. </el-form-item>
  95. </el-col> -->
  96. <el-col>
  97. <el-form-item
  98. label="位置编码"
  99. size="default"
  100. prop="locationCode"
  101. :rules="formRules.isNotNull"
  102. >
  103. <el-input
  104. v-model="tableForm.locationCode"
  105. placeholder="请输入位置编码"
  106. />
  107. </el-form-item>
  108. </el-col>
  109. <el-col :span="24">
  110. <el-form-item label="备注" size="default">
  111. <el-input
  112. type="textarea"
  113. v-model="tableForm.remarks"
  114. placeholder="请输入备注"
  115. />
  116. </el-form-item>
  117. </el-col>
  118. <!-- <el-col>
  119. <el-form-item label="位置英文描述" size="default">
  120. <el-input
  121. v-model="tableForm.englishDescribe"
  122. placeholder="请输入位置英文描述"
  123. />
  124. </el-form-item>
  125. </el-col> -->
  126. </el-row>
  127. </el-form>
  128. </div>
  129. </Dialog>
  130. </div>
  131. </div>
  132. </template>
  133. <script setup lang="ts">
  134. import DataTable from "@/components/tableTemp/index.vue";
  135. import Minheader from "@/components/minheader/index.vue";
  136. import Dialog from "@/components/dialog/index.vue";
  137. import { Query, GeneralDataReception } from "@/api/webApi";
  138. import { ElMessage } from "element-plus";
  139. const formRules = useElement().formRules;
  140. const route = useRoute();
  141. const page = ref<number>(0); //分页参数
  142. const dataContent = ref<object>({});
  143. const noMore = ref<Boolean>(false);
  144. const rowTitle = ref<String>("");
  145. const tableCols = ref([]); //表头数据
  146. const serviceId = ref<String>("");
  147. const tableObj = ref({}); //增删改数据缓存
  148. const flag = ref<Boolean>(false); //弹窗开关
  149. const type = ref<String>(""); //判断是否删除
  150. const msgTitle = ref<String>("新增位置设置"); //弹窗标题
  151. const tableColsCopys = reactive<Object>({}); //弹窗
  152. const tableForm = reactive({
  153. positionID: "",
  154. positionSN: "",
  155. positionDescribe: "",
  156. englishDescribe: "",
  157. locationCode: "",
  158. terminalID: "",
  159. terminalName: "",
  160. remarks: "",
  161. event: "",
  162. }); //弹窗内容
  163. //列表
  164. tableForm.terminalID = route.query.terminalID;
  165. tableForm.terminalName = route.query.terminalName;
  166. const tableData = ref([]);
  167. //表头
  168. const state = reactive({
  169. list: [
  170. { label: "位置名称", key: "name" },
  171. { label: "位置所属节点", key: "china" },
  172. { label: "位置标识", key: "englin" },
  173. { label: "位置编码", key: "two" },
  174. { label: "位置描述", key: "three" },
  175. ],
  176. listLoading: true,
  177. });
  178. const tableBtnGroup = ref([
  179. {
  180. name: "编辑",
  181. className: "editBtn",
  182. param: 2,
  183. is: "position_edit_button",
  184. },
  185. {
  186. name: "删除",
  187. className: "delBtn",
  188. param: 3,
  189. is: "location_delete_button",
  190. },
  191. ]);
  192. //新增
  193. const addForm = () => {
  194. msgTitle.value = "新增位置";
  195. tableForm.event = 1;
  196. flag.value = true;
  197. type.value = "";
  198. };
  199. //取消
  200. const resetForm = () => {
  201. positionSettingForm.value?.resetFields()
  202. flag.value = false;
  203. // tableForm.positionID = "";
  204. // tableForm.positionSN = "";
  205. // tableForm.positionDescribe = "";
  206. // tableForm.englishDescribe = "";
  207. // tableForm.locationCode = "";
  208. // tableForm.remarks = "";
  209. };
  210. //删除
  211. const eleDialog = () => {
  212. msgTitle.value = "删除位置";
  213. flag.value = true;
  214. type.value = "del";
  215. };
  216. const delRemove = () => {
  217. tableForm.event = 3;
  218. generalDataReception(tableForm);
  219. };
  220. //删除
  221. const delRest = () => {
  222. flag.value = false;
  223. };
  224. //编辑-删除
  225. const btnClick = (row, index, param) => {
  226. if (param === 2) {
  227. msgTitle.value = "编辑位置";
  228. flag.value = true;
  229. type.value = "";
  230. tableForm.event = 2;
  231. tableForm.positionID = index.positionID;
  232. tableForm.positionSN = index.positionSN;
  233. tableForm.positionDescribe = index.positionDescribe;
  234. tableForm.englishDescribe = index.englishDescribe;
  235. tableForm.locationCode = index.locationCode;
  236. tableForm.terminalID = index.terminalID;
  237. tableForm.remarks = index.remarks;
  238. } else if (param === 3) {
  239. msgTitle.value = "删除位置";
  240. flag.value = true;
  241. type.value = "del";
  242. tableForm.event = 3;
  243. tableForm.positionID = index.positionID;
  244. tableForm.positionSN = index.positionSN;
  245. tableForm.positionDescribe = index.positionDescribe;
  246. tableForm.englishDescribe = index.englishDescribe;
  247. tableForm.locationCode = index.locationCode;
  248. tableForm.terminalID = index.terminalID;
  249. } else if (param === 4) {
  250. }
  251. };
  252. //获取表格数据
  253. const getQuery = async () => {
  254. try {
  255. const { code, returnData } = await Query({
  256. id: DATACONTENT_ID.airpositTableId,
  257. needPage: ++page.value,
  258. dataContent: [route.query.terminalID],
  259. });
  260. if (code === "0") {
  261. if (returnData.listValues.length === 0) {
  262. page.value--;
  263. noMore.value = true;
  264. }
  265. const titleColumn = returnData.columnSet.find(
  266. (item) => item.needShow === 1
  267. );
  268. if (titleColumn) {
  269. rowTitle.value = titleColumn.columnName;
  270. }
  271. tableData.value.push(...returnData.listValues);
  272. tableCols.value = returnData.columnSet;
  273. tableData.value.forEach((element) => {
  274. element.terminalName = route.query.terminalName;
  275. });
  276. tableCols.value.forEach((element) => {
  277. element.label = element.columnLabel;
  278. element.key = element.columnName;
  279. // if (element.columnName === "queryTemplate") {
  280. // element.width = "300px";
  281. // }
  282. });
  283. serviceId.value = returnData.submitID;
  284. } else {
  285. page.value--;
  286. }
  287. } catch (error) {
  288. page.value--;
  289. }
  290. };
  291. // //确认提交
  292. // const submitForm = () => {
  293. // generalDataReception(tableForm);
  294. // };
  295. //确认提交
  296. const positionSettingForm: any = ref(null);
  297. const submitForm = () => {
  298. positionSettingForm.value.validate((valid: any) => {
  299. if (valid) {
  300. generalDataReception(tableForm);
  301. } else {
  302. return false;
  303. }
  304. });
  305. };
  306. const resetTable = () => {
  307. page.value = 0;
  308. noMore.value = false;
  309. tableData.value = [];
  310. };
  311. //新增-编辑-删除
  312. const generalDataReception = async (data) => {
  313. try {
  314. let obj = {
  315. terminalID: route.query.terminalID,
  316. };
  317. data = {
  318. ...data,
  319. obj,
  320. };
  321. const { code } = await GeneralDataReception({
  322. serviceId: serviceId.value,
  323. dataContent: JSON.stringify(data),
  324. });
  325. if (code == 0) {
  326. ElMessage.success(`操作成功`);
  327. // this.$message.success("操作成功");
  328. resetTable();
  329. getQuery();
  330. resetForm();
  331. flag.value = false;
  332. // rmFlag.value = false;
  333. tableObj.value = {};
  334. // this.$router.go(0);
  335. } else {
  336. ElMessage.error(`操作失败`);
  337. // this.$message.error("操作失败");
  338. // this.flag = false;
  339. // this.rmFlag = false;
  340. tableObj.value = {};
  341. resetForm();
  342. }
  343. } catch (error) {
  344. flag.value = false;
  345. // rmFlag.value = false;
  346. tableObj.value = {};
  347. resetForm();
  348. }
  349. };
  350. getQuery();
  351. </script>
  352. <style lang="scss" scoped>
  353. ::v-deep .el-form-item__label {
  354. width: 110px;
  355. }
  356. </style>