index.vue 9.8 KB

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