index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <div>
  3. <basic-container>
  4. <!-- @resetColumn="resetColumn('crud', 'option', 'optionBack', 458)"-->
  5. <!-- @saveColumn="saveColumn('crud', 'option', 'optionBack', 458)"-->
  6. <avue-crud
  7. :option="option"
  8. :data="dataList"
  9. ref="crud"
  10. v-model="form"
  11. :page.sync="page"
  12. :search.sync="search"
  13. :table-loading="loading"
  14. @search-change="searchChange"
  15. @current-change="currentChange"
  16. @size-change="sizeChange"
  17. @refresh-change="refreshChange"
  18. @on-load="onLoad"
  19. @selection-change="selectionChange"
  20. >
  21. <template slot="menu" slot-scope="{ row, index }">
  22. <!-- <el-button v-if="row.locked==0" type="text" icon="el-icon-unlock" size="small" @click="rowUnlock(row, index)">加锁</el-button> -->
  23. <!-- <el-button v-if="row.locked==1" type="text" icon="el-icon-unlock" size="small" @click="rowOnlock(row, index)">解锁</el-button> -->
  24. <el-button v-if="row.locked == 0" type="text" icon="el-icon-unlock" size="small" @click="allClick(row)">解锁</el-button>
  25. <el-button :disabled="row.locked != 0" type="text" icon="el-icon-delete" size="small" @click="rowDel(row, index)">删除</el-button>
  26. </template>
  27. <template slot="menuLeft">
  28. <el-button type="primary" size="small" @click="allClick()" :disabled="selectionList.length == 0">一键解锁 </el-button>
  29. </template>
  30. </avue-crud>
  31. </basic-container>
  32. </div>
  33. </template>
  34. <script>
  35. import option from "./config/mainList.json";
  36. import { lockList, lockRemove, unLock } from "@/api/lock/businessUnlocking";
  37. import { getWorkDicts } from "@/api/system/dictbiz";
  38. export default {
  39. name: "index",
  40. data() {
  41. return {
  42. selectionList: [],
  43. option: {},
  44. optionBack: {
  45. height: "auto",
  46. calcHeight: 30,
  47. menuWidth: 120,
  48. tip: false,
  49. searchShow: true,
  50. searchMenuSpan: 6,
  51. border: true,
  52. index: true,
  53. addBtn: false,
  54. viewBtn: false,
  55. editBtn: false,
  56. delBtn: false,
  57. selection: true,
  58. searchIcon: true,
  59. align: "center",
  60. searchIndex: 4,
  61. column: [
  62. {
  63. label: "业务编号",
  64. prop: "srcBillNo",
  65. width: 120,
  66. search: true,
  67. overHidden: true,
  68. sortable: true
  69. },
  70. {
  71. label: "单据日期",
  72. prop: "billDate",
  73. width: 120,
  74. overHidden: true,
  75. search: true,
  76. searchProp: "billDateList",
  77. type: "date",
  78. unlinkPanels: true,
  79. searchRange: true,
  80. format: "yyyy-MM-dd",
  81. valueFormat: "yyyy-MM-dd HH:mm:ss",
  82. searchDefaultTime: ["00:00:00", "23:59:59"],
  83. sortable: true
  84. },
  85. {
  86. label: "船名",
  87. prop: "srcVesselEnName",
  88. width: 120,
  89. overHidden: true,
  90. search: true,
  91. sortable: true
  92. },
  93. {
  94. label: "航次",
  95. prop: "srcVoyageNo",
  96. width: 120,
  97. overHidden: true,
  98. search: true,
  99. sortable: true
  100. },
  101. {
  102. label: "MBLNO",
  103. prop: "srcMblno",
  104. width: 120,
  105. overHidden: true,
  106. search: true,
  107. sortable: true
  108. },
  109. {
  110. label: "Reference",
  111. prop: "rcRefno",
  112. width: 120,
  113. overHidden: true,
  114. search: true,
  115. sortable: true
  116. },
  117. {
  118. label: "加解锁操作时间",
  119. prop: "lockedTime",
  120. width: 120,
  121. overHidden: true,
  122. sortable: true
  123. },
  124. {
  125. label: "累计已解锁次数",
  126. prop: "unlockedCount",
  127. width: 120,
  128. overHidden: true
  129. },
  130. {
  131. label: "操作人",
  132. prop: "operatorName",
  133. width: 120,
  134. overHidden: true
  135. },
  136. {
  137. label: "业务类型",
  138. prop: "businessTypeName",
  139. width: 120,
  140. search: true,
  141. overHidden: true,
  142. sortable: true
  143. }
  144. ]
  145. },
  146. dataList: [],
  147. form: {},
  148. page: {
  149. pageSize: 10,
  150. pagerCount: 5,
  151. total: 0
  152. },
  153. search: {},
  154. loading: false
  155. };
  156. },
  157. async created() {
  158. // this.option = await this.getColumnData(this.getColumnName(458), this.optionBack);
  159. this.option = this.optionBack;
  160. },
  161. filters: {
  162. moudleNameFormat(row, moudleOption) {
  163. let name;
  164. moudleOption.map(e => {
  165. if (row == e.dictKey) {
  166. name = e.dictValue;
  167. }
  168. });
  169. return name;
  170. }
  171. },
  172. methods: {
  173. selectionChange(list) {
  174. this.selectionList = list;
  175. },
  176. searchChange(params, done) {
  177. this.onLoad(this.page, params);
  178. done();
  179. },
  180. currentChange(val) {
  181. this.page.currentPage = val;
  182. },
  183. sizeChange(val) {
  184. this.page.currentPage = 1;
  185. this.page.pageSize = val;
  186. },
  187. refreshChange() {
  188. this.onLoad(this.page, this.search);
  189. },
  190. onLoad(page, params) {
  191. this.dataList.forEach(item => {
  192. this.$refs.crud.toggleRowExpansion(item, false);
  193. });
  194. this.loading = true;
  195. lockList(page.currentPage, page.pageSize, params)
  196. .then(res => {
  197. this.dataList = res.data.data.records ? res.data.data.records : [];
  198. this.page.total = res.data.data.total;
  199. if (this.page.total) {
  200. this.option.height = window.innerHeight - 260;
  201. }
  202. this.dataList.forEach(item => {
  203. this.$set(item, "insideList", []);
  204. this.$set(item, "loading", true);
  205. });
  206. this.$nextTick(() => {
  207. this.$refs.crud.refreshTable();
  208. });
  209. })
  210. .finally(() => {
  211. this.loading = false;
  212. });
  213. },
  214. rowDel(row) {
  215. this.$confirm("确定将选择数据删除?", {
  216. confirmButtonText: "确定",
  217. cancelButtonText: "取消",
  218. type: "warning"
  219. }).then(() => {
  220. lockRemove({ ids: row.id }).then(res => {
  221. this.onLoad(this.page);
  222. this.$message({
  223. type: "success",
  224. message: "操作成功!"
  225. });
  226. });
  227. });
  228. },
  229. // 解锁
  230. rowUnlock(row, index) {
  231. this.$confirm("是否确认解锁?", "提示", {
  232. confirmButtonText: "确定",
  233. cancelButtonText: "取消",
  234. type: "warning"
  235. }).then(() => {
  236. this.$message({
  237. type: "success",
  238. message: "操作成功!"
  239. });
  240. this.onLoad(this.page, this.search);
  241. });
  242. },
  243. //加锁
  244. rowOnlock(row, index) {
  245. this.$confirm("是否确认加锁?", "提示", {
  246. confirmButtonText: "确定",
  247. cancelButtonText: "取消",
  248. type: "warning"
  249. }).then(() => {
  250. this.$message({
  251. type: "success",
  252. message: "操作成功!"
  253. });
  254. this.onLoad(this.page, this.search);
  255. });
  256. },
  257. allClick(row) {
  258. let arr = [];
  259. let ids = null;
  260. if (row) {
  261. arr.push(row.id);
  262. } else {
  263. this.selectionList.forEach(e => {
  264. if (e.locked == 0) {
  265. arr.push(e.id);
  266. }
  267. });
  268. }
  269. if (arr.length == 0) {
  270. this.$message.warning("请勾选未解锁的业务!");
  271. return;
  272. }
  273. console.log(arr);
  274. ids = arr.join(",");
  275. // this.$confirm("是否确认解锁?", "提示", {
  276. // confirmButtonText: "确定",
  277. // cancelButtonText: "取消",
  278. // type: "warning"
  279. // }).then(() => {
  280. unLock({ ids: ids }).then(() => {
  281. this.$message({
  282. type: "success",
  283. message: "操作成功!"
  284. });
  285. this.page.currentPage = 1;
  286. this.onLoad(this.page, { parentId: 0 });
  287. });
  288. // })
  289. },
  290. //自定义列保存
  291. async saveColumn(ref, option, optionBack, code) {
  292. /**
  293. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  294. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  295. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  296. */
  297. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  298. if (inSave) {
  299. this.$message.success("保存成功");
  300. //关闭窗口
  301. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  302. this.searchReset();
  303. }
  304. },
  305. //自定义列重置
  306. async resetColumn(ref, option, optionBack, code) {
  307. this[option] = this[optionBack];
  308. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  309. if (inSave) {
  310. this.$message.success("重置成功");
  311. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  312. this.searchReset();
  313. }
  314. }
  315. }
  316. };
  317. </script>
  318. <style scoped></style>