index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. :flag="flag"
  22. :type="type"
  23. :msgTitle="msgTitle"
  24. @resetForm="resetForm"
  25. @delRest="delRest"
  26. @submitForm="submitForm"
  27. @delRemove="delRemove"
  28. >
  29. <div class="diacont">
  30. <el-form
  31. :model="tableForm"
  32. :rules="formRules"
  33. ref="specialCargoMaintenanceForm"
  34. >
  35. <el-row :gutter="24">
  36. <el-col>
  37. <el-form-item
  38. label="类型名称"
  39. size="default"
  40. prop="specialTypeName"
  41. :rules="formRules.isNotNull"
  42. >
  43. <el-input
  44. v-model="tableForm.specialTypeName"
  45. placeholder="请输入类型名称"
  46. />
  47. </el-form-item>
  48. </el-col>
  49. <el-col>
  50. <el-form-item
  51. label="类型编码"
  52. size="default"
  53. prop="specialType"
  54. :rules="formRules.isNotNull"
  55. >
  56. <el-input
  57. v-model="tableForm.specialType"
  58. placeholder="请输入类型编码"
  59. />
  60. </el-form-item>
  61. </el-col>
  62. <el-col>
  63. <el-form-item label="描述" size="default">
  64. <el-input
  65. type="textarea"
  66. v-model="tableForm.specialTypeDescribe"
  67. placeholder="请输入描述"
  68. />
  69. </el-form-item>
  70. </el-col>
  71. </el-row>
  72. </el-form>
  73. </div>
  74. </Dialog>
  75. </div>
  76. </div>
  77. </template>
  78. <script setup lang="ts">
  79. import DataTable from "@/components/tableTemp/index.vue";
  80. import Minheader from "@/components/minheader/index.vue";
  81. import Dialog from "@/components/dialog/index.vue";
  82. import { Query, GeneralDataReception } from "@/api/webApi";
  83. import { ElMessage } from "element-plus";
  84. const formRules = useElement().formRules;
  85. const page = ref<number>(0); //分页参数
  86. const dataContent = ref<object>({});
  87. const noMore = ref<Boolean>(false);
  88. const rowTitle = ref<String>("");
  89. const tableCols = ref([]); //表头数据
  90. const serviceId = ref<String>("");
  91. const tableObj = ref({}); //增删改数据缓存
  92. const flag = ref<Boolean>(false); //弹窗开关
  93. const type = ref<String>(""); //判断是否删除
  94. const msgTitle = ref<String>("新增特殊货物类型维护"); //弹窗标题
  95. const tableColsCopys = reactive<Object>({}); //弹窗
  96. const tableForm = reactive({
  97. specialTypeID: "",
  98. specialType: "",
  99. specialTypeName: "",
  100. specialTypeDescribe: "",
  101. event: "",
  102. }); //弹窗内容
  103. //列表
  104. const tableData = ref([]);
  105. //表头
  106. const state = reactive({
  107. list: [
  108. { label: "类型名称", key: "name" },
  109. { label: "类型编码", key: "china" },
  110. { label: "描述", key: "englin" },
  111. ],
  112. listLoading: true,
  113. });
  114. const tableBtnGroup = ref([
  115. {
  116. name: "编辑",
  117. className: "editBtn",
  118. param: 2,
  119. },
  120. {
  121. name: "删除",
  122. className: "delBtn",
  123. param: 3,
  124. },
  125. ]);
  126. //新增
  127. const addForm = () => {
  128. msgTitle.value = "新增特殊货物类型维护";
  129. flag.value = true;
  130. type.value = "";
  131. tableForm.event = 1;
  132. };
  133. //取消
  134. const resetForm = () => {
  135. flag.value = false;
  136. tableForm.specialTypeID = "";
  137. tableForm.specialType = "";
  138. tableForm.specialTypeName = "";
  139. tableForm.specialTypeDescribe = "";
  140. };
  141. //编辑
  142. const editDialog = (data) => {
  143. msgTitle.value = "编辑特殊货物类型维护";
  144. flag.value = true;
  145. type.value = "";
  146. tableForm.name = data.name;
  147. tableForm.china = data.china;
  148. tableForm.englin = data.englin;
  149. };
  150. //删除
  151. const eleDialog = () => {
  152. msgTitle.value = "删除特殊货物类型维护";
  153. flag.value = true;
  154. type.value = "del";
  155. };
  156. const delRemove = () => {
  157. tableForm.event = 3;
  158. generalDataReception(tableForm);
  159. };
  160. //删除
  161. const delRest = () => {
  162. flag.value = false;
  163. };
  164. //编辑-删除
  165. const btnClick = (row, index, param) => {
  166. if (param === 2) {
  167. msgTitle.value = "编辑特殊货物类型维护";
  168. flag.value = true;
  169. type.value = "";
  170. tableForm.event = 2;
  171. tableForm.specialTypeID = index.specialTypeID;
  172. tableForm.specialType = index.specialType;
  173. tableForm.specialTypeName = index.specialTypeName;
  174. tableForm.specialTypeDescribe = index.specialTypeDescribe;
  175. } else if (param === 3) {
  176. msgTitle.value = "删除特殊货物类型维护";
  177. flag.value = true;
  178. type.value = "del";
  179. tableForm.event = 3;
  180. tableForm.specialTypeID = index.specialTypeID;
  181. tableForm.specialType = index.specialType;
  182. tableForm.specialTypeName = index.specialTypeName;
  183. tableForm.specialTypeDescribe = index.specialTypeDescribe;
  184. } else if (param === 4) {
  185. }
  186. };
  187. //获取表格数据
  188. const getQuery = async () => {
  189. try {
  190. const { code, returnData } = await Query({
  191. id: DATACONTENT_ID.bagTableId,
  192. needPage: ++page.value,
  193. dataContent: Object.values(dataContent.value),
  194. });
  195. if (code === "0") {
  196. if (returnData.listValues.length === 0) {
  197. page.value--;
  198. noMore.value = true;
  199. }
  200. const titleColumn = returnData.columnSet.find(
  201. (item) => item.needShow === 1
  202. );
  203. if (titleColumn) {
  204. rowTitle.value = titleColumn.columnName;
  205. }
  206. tableData.value.push(...returnData.listValues);
  207. tableCols.value = returnData.columnSet;
  208. tableCols.value.forEach((element) => {
  209. element.label = element.columnLabel;
  210. element.key = element.columnName;
  211. // if (element.columnName === "queryTemplate") {
  212. // element.width = "300px";
  213. // }
  214. });
  215. serviceId.value = returnData.submitID;
  216. } else {
  217. page.value--;
  218. }
  219. } catch (error) {
  220. page.value--;
  221. }
  222. };
  223. //确认提交
  224. const specialCargoMaintenanceForm: any = ref(null);
  225. const submitForm = () => {
  226. specialCargoMaintenanceForm.value.validate((valid: any) => {
  227. if (valid) {
  228. generalDataReception(tableForm);
  229. } else {
  230. return false;
  231. }
  232. });
  233. };
  234. const resetTable = () => {
  235. page.value = 0;
  236. noMore.value = false;
  237. tableData.value = [];
  238. };
  239. //新增-编辑-删除
  240. const generalDataReception = async (data) => {
  241. try {
  242. data = {
  243. ...data,
  244. };
  245. const { code } = await GeneralDataReception({
  246. serviceId: serviceId.value,
  247. dataContent: JSON.stringify(data),
  248. });
  249. if (code == 0) {
  250. ElMessage.success(`操作成功`);
  251. // this.$message.success("操作成功");
  252. resetTable();
  253. getQuery();
  254. resetForm();
  255. flag.value = false;
  256. // rmFlag.value = false;
  257. tableObj.value = {};
  258. // this.$router.go(0);
  259. } else {
  260. ElMessage.error(`操作失败`);
  261. // this.$message.error("操作失败");
  262. // this.flag = false;
  263. // this.rmFlag = false;
  264. tableObj.value = {};
  265. resetForm();
  266. }
  267. } catch (error) {
  268. flag.value = false;
  269. // rmFlag.value = false;
  270. tableObj.value = {};
  271. resetForm();
  272. }
  273. };
  274. getQuery();
  275. </script>
  276. <style lang="scss" scoped>
  277. ::v-deep .el-form-item__label {
  278. width: 80px;
  279. }
  280. </style>