index.vue 9.1 KB

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