index.vue 16 KB

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