index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <!-- 贸易条款 -->
  2. <template>
  3. <basic-container>
  4. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :permission="permissionList"
  5. id="out-table" :header-cell-class-name="headerClassName" :before-open="beforeOpen" :search.sync="search"
  6. v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel"
  7. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  8. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  9. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 295)"
  10. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 295)" @on-load="onLoad">
  11. <template slot="code" slot-scope="scope">
  12. <avue-text-ellipsis :text="scope.row.code" :height="30" use-tooltip placement="top">
  13. <small slot="more">...</small>
  14. </avue-text-ellipsis>
  15. </template>
  16. <template slot="cnName" slot-scope="scope">
  17. <avue-text-ellipsis :text="scope.row.cnName" :height="30" use-tooltip placement="top">
  18. <small slot="more">...</small>
  19. </avue-text-ellipsis>
  20. </template>
  21. <template slot="enName" slot-scope="scope">
  22. <avue-text-ellipsis :text="scope.row.enName" :height="30" use-tooltip placement="top">
  23. <small slot="more">...</small>
  24. </avue-text-ellipsis>
  25. </template>
  26. <template slot="remarks" slot-scope="scope">
  27. <avue-text-ellipsis :text="scope.row.remarks" :height="30" use-tooltip placement="top">
  28. <small slot="more">...</small>
  29. </avue-text-ellipsis>
  30. </template>
  31. <template slot="menuLeft">
  32. <el-button type="primary" size="small" icon="el-icon-plus" @click="addbtnfun()">新建贸易条款
  33. </el-button>
  34. <el-button type="danger" size="small" icon="el-icon-delete" plain v-if="permission.btrademodes_delete"
  35. @click="handleDelete">删 除
  36. </el-button>
  37. <el-button type="warning" size="small" icon="el-icon-printer" @click="excelBox = true">导入
  38. </el-button>
  39. <el-button type="success" size="small" @click="handleExport" icon="el-icon-printer">导出</el-button>
  40. </template>
  41. <template slot-scope="scope" slot="menu">
  42. <el-button type="text" icon="el-icon-view" size="small" @click.stop="rowViewfun(scope.row, scope.index)">查看
  43. </el-button>
  44. <el-button type="text" icon="el-icon-edit" size="small" @click.stop="rowEditfun(scope.row, scope.index)">编辑
  45. </el-button>
  46. <el-button type="text" icon="el-icon-edit" size="small" @click.stop="rowDel(scope.row, scope.index)">删除
  47. </el-button>
  48. </template>
  49. </avue-crud>
  50. <el-dialog title="导入往来单位" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false"
  51. v-dialog-drag>
  52. <avue-form :option="excelOption" v-model="excelForm" :table-loading="excelLoading" :upload-before="uploadBefore"
  53. :upload-after="onSuccess">
  54. <template slot="excelTemplate">
  55. <el-button type="primary" @click="handleGet">
  56. 点击下载<i class="el-icon-download el-icon--right"></i>
  57. </el-button>
  58. </template>
  59. </avue-form>
  60. <p style="text-align: center;color: #DC0505">
  61. 温馨提示 第一次导入时请先下载模板
  62. </p>
  63. </el-dialog>
  64. </basic-container>
  65. </template>
  66. <script>
  67. import { getBtrademodesList, getBtrademodesDetail, addBtrademodes, updateBtrademodes, removeBtrademodes } from "@/api/iosBasicData/btrademodes";
  68. import { mapGetters } from "vuex";
  69. import { getToken } from "@/util/auth";
  70. export default {
  71. data() {
  72. return {
  73. form: {},
  74. query: {},
  75. loading: true,
  76. excelBox: false,
  77. search: {},
  78. excelForm: {},
  79. excelLoading: false,
  80. excelOption: {
  81. submitBtn: false,
  82. emptyBtn: false,
  83. column: [
  84. {
  85. label: "模板下载",
  86. prop: "excelTemplate",
  87. formslot: true,
  88. span: 24
  89. },
  90. {
  91. label: "模板上传",
  92. prop: "excelFile",
  93. type: "upload",
  94. drag: true,
  95. loadText: "模板上传中,请稍等",
  96. span: 24,
  97. propsHttp: {
  98. res: "data"
  99. },
  100. tip: "请上传 .xls,.xlsx 标准格式文件",
  101. action: "/api/blade-los/btrademodes/importBTradeModes"
  102. }
  103. ]
  104. },
  105. page: {
  106. pageSize: 10,
  107. currentPage: 1,
  108. total: 0
  109. },
  110. selectionList: [],
  111. option: {},
  112. optionBack: {
  113. height: 'auto',
  114. stripe: true,
  115. calcHeight: 30,
  116. searchIcon: true,
  117. searchIndex: 3,
  118. tip: false,
  119. searchShow: true,
  120. searchMenuSpan: 6,
  121. border: true,
  122. index: true,
  123. viewBtn: true,
  124. selection: true,
  125. dialogClickModal: false,
  126. column: [
  127. // {
  128. // label: "主键",
  129. // prop: "id",
  130. // rules: [{
  131. // required: true,
  132. // message: "请输入主键",
  133. // trigger: "blur"
  134. // }]
  135. // },
  136. // {
  137. // label: "创建人 Id",
  138. // prop: "createUser",
  139. // rules: [{
  140. // required: true,
  141. // message: "请输入创建人 Id",
  142. // trigger: "blur"
  143. // }]
  144. // },
  145. // {
  146. // label: "创建人",
  147. // prop: "createUserName",
  148. // rules: [{
  149. // required: true,
  150. // message: "请输入创建人",
  151. // trigger: "blur"
  152. // }]
  153. // },
  154. // {
  155. // label: "创建部门 Id",
  156. // prop: "createDept",
  157. // rules: [{
  158. // required: true,
  159. // message: "请输入创建部门 Id",
  160. // trigger: "blur"
  161. // }]
  162. // },
  163. // {
  164. // label: "创建部门",
  165. // prop: "createDeptName",
  166. // rules: [{
  167. // required: true,
  168. // message: "请输入创建部门",
  169. // trigger: "blur"
  170. // }]
  171. // },
  172. // {
  173. // label: "创建时间",
  174. // prop: "createTime",
  175. // rules: [{
  176. // required: true,
  177. // message: "请输入创建时间",
  178. // trigger: "blur"
  179. // }]
  180. // },
  181. // {
  182. // label: "修改人 Id",
  183. // prop: "updateUser",
  184. // rules: [{
  185. // required: true,
  186. // message: "请输入修改人 Id",
  187. // trigger: "blur"
  188. // }]
  189. // },
  190. // {
  191. // label: "修改人",
  192. // prop: "updateUserName",
  193. // rules: [{
  194. // required: true,
  195. // message: "请输入修改人",
  196. // trigger: "blur"
  197. // }]
  198. // },
  199. // {
  200. // label: "修改时间",
  201. // prop: "updateTime",
  202. // rules: [{
  203. // required: true,
  204. // message: "请输入修改时间",
  205. // trigger: "blur"
  206. // }]
  207. // },
  208. {
  209. label: "编码",
  210. prop: "code",
  211. width: "180",
  212. search: true,
  213. slot: true,
  214. rules: [{
  215. required: true,
  216. message: "请输入编码",
  217. trigger: "blur"
  218. }]
  219. },
  220. {
  221. label: "中文名称",
  222. prop: "cnName",
  223. width: "180",
  224. search: true,
  225. slot: true,
  226. rules: [{
  227. required: true,
  228. message: "请输入中文名称",
  229. trigger: "blur"
  230. }]
  231. },
  232. {
  233. label: "英文名称",
  234. prop: "enName",
  235. width: "180",
  236. search: true,
  237. slot: true,
  238. rules: [{
  239. required: true,
  240. message: "请输入英文名称",
  241. trigger: "blur"
  242. }]
  243. },
  244. {
  245. label: "简称",
  246. prop: "shortName",
  247. },
  248. {
  249. label: "单一窗口编码",
  250. prop: "codeSw",
  251. width: 160,
  252. },
  253. {
  254. label: "版本",
  255. prop: "version",
  256. display: false,
  257. },
  258. {
  259. label: "状态",
  260. prop: "status",
  261. type: "select",
  262. dicData: [{
  263. label: '启用',
  264. value: 0
  265. }, {
  266. label: '停用',
  267. value: 1
  268. }],
  269. value: 0
  270. },
  271. // {
  272. // label: "是否已删除(0 否 1是)",
  273. // prop: "isDeleted",
  274. // rules: [{
  275. // required: true,
  276. // message: "请输入是否已删除(0 否 1是)",
  277. // trigger: "blur"
  278. // }]
  279. // },
  280. {
  281. label: "备注",
  282. prop: "remarks",
  283. type: 'textarea',
  284. width: "180",
  285. span: 24,
  286. minRows: 3,
  287. slot: true
  288. },
  289. ]
  290. },
  291. data: []
  292. };
  293. },
  294. async created() {
  295. this.option = await this.getColumnData(this.getColumnName(295), this.optionBack);
  296. },
  297. computed: {
  298. ...mapGetters(["permission"]),
  299. permissionList() {
  300. return {
  301. addBtn: this.vaildData(this.permission.btrademodes_add, false),
  302. viewBtn: this.vaildData(this.permission.btrademodes_view, false),
  303. delBtn: this.vaildData(this.permission.btrademodes_delete, false),
  304. editBtn: this.vaildData(this.permission.btrademodes_edit, false)
  305. };
  306. },
  307. ids() {
  308. let ids = [];
  309. this.selectionList.forEach(ele => {
  310. ids.push(ele.id);
  311. });
  312. return ids.join(",");
  313. }
  314. },
  315. methods: {
  316. // 导出
  317. handleExport() {
  318. var condition = ''
  319. for (const key in this.search) {
  320. var value = this.search[key]
  321. if (value) {
  322. condition += `&${key}=${this.search[key]}`
  323. }
  324. }
  325. this.$confirm('是否导出贸易条款?', '提示', {
  326. confirmButtonText: '确定',
  327. cancelButtonText: '取消',
  328. type: 'warning'
  329. }).then(() => {
  330. window.open(
  331. `/api/blade-los/btrademodes/exportBTradeModes?${this.website.tokenHeader
  332. }=${getToken()}${condition}`
  333. );
  334. }).catch(() => {
  335. this.$message({
  336. type: 'info',
  337. message: '已取消' //
  338. });
  339. })
  340. },
  341. uploadBefore(file, done, loading) {
  342. done();
  343. loading = true;
  344. },
  345. // 上传成功
  346. onSuccess(res, done, loading, column) {
  347. this.excelBox = false;
  348. this.$message.success("导入成功!");
  349. loading = false;
  350. this.onLoad(this.page);
  351. done();
  352. },
  353. // 下载模板
  354. handleGet() {
  355. window.open(
  356. `/api/blade-los/btrademodes/exportBTradeModes/template?${this.website.tokenHeader
  357. }=${getToken()}`
  358. );
  359. },
  360. // 新增
  361. addbtnfun() {
  362. this.form.status = 0
  363. this.$refs.crud.rowAdd()
  364. },
  365. // 查看
  366. rowViewfun(row, index) {
  367. this.extendedDisabled = true
  368. this.$refs.crud.rowView(row, index)
  369. },
  370. // 编辑
  371. rowEditfun(row, index) {
  372. getBtrademodesDetail(row.id).then(res => {
  373. this.form = res.data.data;
  374. this.$refs.crud.rowEdit(row, index)
  375. });
  376. },
  377. rowSave(row, done, loading) {
  378. addBtrademodes(row).then(() => {
  379. this.onLoad(this.page);
  380. this.$message({
  381. type: "success",
  382. message: "操作成功!"
  383. });
  384. done();
  385. }, error => {
  386. loading();
  387. window.console.log(error);
  388. });
  389. },
  390. rowUpdate(row, index, done, loading) {
  391. updateBtrademodes(row).then(() => {
  392. this.onLoad(this.page);
  393. this.$message({
  394. type: "success",
  395. message: "操作成功!"
  396. });
  397. done();
  398. }, error => {
  399. loading();
  400. console.log(error);
  401. });
  402. },
  403. rowDel(row) {
  404. if (row.status === 1) {
  405. this.$confirm("确定将选择数据删除?", {
  406. confirmButtonText: "确定",
  407. cancelButtonText: "取消",
  408. type: "warning"
  409. })
  410. .then(() => {
  411. return removeBtrademodes(row.id);
  412. })
  413. .then(() => {
  414. this.onLoad(this.page);
  415. this.$message({
  416. type: "success",
  417. message: "操作成功!"
  418. });
  419. });
  420. } else {
  421. this.$message({
  422. message: '非禁用状态无法删除',
  423. type: 'warning'
  424. });
  425. }
  426. },
  427. handleDelete() {
  428. if (this.selectionList.length === 0) {
  429. this.$message.warning("请选择至少一条数据");
  430. return;
  431. }
  432. this.$confirm("确定将选择数据删除?", {
  433. confirmButtonText: "确定",
  434. cancelButtonText: "取消",
  435. type: "warning"
  436. })
  437. .then(() => {
  438. return removeBtrademodes(this.ids);
  439. })
  440. .then(() => {
  441. this.onLoad(this.page);
  442. this.$message({
  443. type: "success",
  444. message: "操作成功!"
  445. });
  446. this.$refs.crud.toggleSelection();
  447. });
  448. },
  449. beforeOpen(done, type) {
  450. if (["edit", "view"].includes(type)) {
  451. getBtrademodesDetail(this.form.id).then(res => {
  452. this.form = res.data.data;
  453. });
  454. }
  455. done();
  456. },
  457. searchReset() {
  458. this.query = {};
  459. this.onLoad(this.page);
  460. },
  461. searchChange(params, done) {
  462. this.query = params;
  463. this.page.currentPage = 1;
  464. this.onLoad(this.page, params);
  465. done();
  466. },
  467. selectionChange(list) {
  468. this.selectionList = list;
  469. },
  470. selectionClear() {
  471. this.selectionList = [];
  472. this.$refs.crud.toggleSelection();
  473. },
  474. currentChange(currentPage) {
  475. this.page.currentPage = currentPage;
  476. },
  477. sizeChange(pageSize) {
  478. this.page.pageSize = pageSize;
  479. },
  480. refreshChange() {
  481. this.onLoad(this.page, this.query);
  482. },
  483. onLoad(page, params = {}) {
  484. this.loading = true;
  485. getBtrademodesList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  486. const data = res.data.data;
  487. this.page.total = data.total;
  488. this.data = data.records;
  489. this.loading = false;
  490. this.selectionClear();
  491. });
  492. },
  493. //自定义列保存
  494. async saveColumnTwo(ref, option, optionBack, code) {
  495. /**
  496. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  497. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  498. * 一定要执行异步操作,要等接口成功返回,才能执行下一行编码
  499. */
  500. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  501. if (inSave) {
  502. this.$message.success("保存成功");
  503. //关闭窗口
  504. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  505. }
  506. },
  507. //自定义列重置
  508. async resetColumnTwo(ref, option, optionBack, code) {
  509. this[option] = this[optionBack];
  510. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  511. if (inSave) {
  512. this.$message.success("重置成功");
  513. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  514. }
  515. },
  516. // 更改表格颜色
  517. headerClassName(tab) {
  518. //颜色间隔
  519. let back = ""
  520. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  521. if (tab.columnIndex % 2 === 0) {
  522. back = "back-one"
  523. } else if (tab.columnIndex % 2 === 1) {
  524. back = "back-two"
  525. }
  526. }
  527. return back;
  528. },
  529. }
  530. };
  531. </script>
  532. <style lang="scss" scoped>
  533. ::v-deep#out-table .back-one {
  534. background: #ecf5ff !important;
  535. }
  536. ::v-deep#out-table .back-two {
  537. background: #ecf5ff !important;
  538. }
  539. /deep/ .el-col-md-8 {
  540. width: 24.33333%;
  541. }
  542. </style>