index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <template>
  2. <div>
  3. <basic-container v-show="isShow">
  4. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :search.sync="query"
  5. v-model="form" id="out-table" :header-cell-class-name="headerClassName" ref="crud" @row-del="rowDel"
  6. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  7. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  8. @resetColumn="resetColumn('crud', 'option', 'optionBack', 442)"
  9. @saveColumn="saveColumn('crud', 'option', 'optionBack', 442)" @on-load="onLoad">
  10. <template slot="menuLeft">
  11. <el-button type="primary" size="small" icon="el-icon-plus" @click="addButton">新 增
  12. </el-button>
  13. </template>
  14. <template slot="menu" slot-scope="{ row, index }">
  15. <el-button size="small" icon="el-icon-edit" type="text" @click="rowEdit(row)">编辑</el-button>
  16. <el-button size="small" icon="el-icon-delete" type="text" @click="rowDel(row)" :disabled="row.status == '已生成'">删除</el-button>
  17. </template>
  18. <template slot="warehouseName" slot-scope="{ row }">
  19. <span style="color: #1e9fff" @click="rowEdit(row)">{{ row.warehouseName }}</span>
  20. </template>
  21. </avue-crud>
  22. </basic-container>
  23. <detailsPage v-if="!isShow" :detailData="detailData" @goBack="goBack"></detailsPage>
  24. </div>
  25. </template>
  26. <script>
  27. import { getList, remove, submit } from "@/api/iosBasicData/storageFeeF";
  28. import detailsPage from "./detailsPage";
  29. import _ from "lodash";
  30. export default {
  31. data() {
  32. return {
  33. detailData: {},
  34. isShow: true,
  35. form: {},
  36. query: {},
  37. loading: false,
  38. page: {
  39. pageSize: 10,
  40. currentPage: 1,
  41. total: 0
  42. },
  43. selectionList: [],
  44. option: {},
  45. optionBack: {
  46. height: 'auto',
  47. calcHeight: 30,
  48. menuWidth: 120,
  49. searchLabelWidth: 100,
  50. searchShow: true,
  51. searchMenuSpan: 12,
  52. border: true,
  53. index: true,
  54. addBtn: false,
  55. viewBtn: false,
  56. editBtn: false,
  57. delBtn: false,
  58. searchIcon: true,
  59. searchIndex: 3,
  60. column: [
  61. {
  62. label: "仓库",
  63. prop: "warehouseName",
  64. search: true,
  65. type: 'select',
  66. filterable: true,
  67. remote: true,
  68. dicUrl: "/api/blade-los/storage/list?cname={{key}}",
  69. props: {
  70. label: 'cname',
  71. value: 'cname',
  72. res: 'data.records'
  73. },
  74. overHidden: true,
  75. },
  76. // {
  77. // label: "计费起始时间",
  78. // prop: "chargingStartDate",
  79. // search: true,
  80. // type: "date",
  81. // format: "yyyy-MM-dd",
  82. // valueFormat: "yyyy-MM-dd 00:00:00",
  83. // overHidden: true
  84. // },
  85. {
  86. label: "计费结束时间",
  87. prop: "chargingEndDate",
  88. search: true,
  89. type: "date",
  90. format: "yyyy-MM-dd",
  91. valueFormat: "yyyy-MM-dd 00:00:00",
  92. overHidden: true
  93. },
  94. {
  95. label: "合计金额",
  96. prop: "amount",
  97. overHidden: true
  98. },
  99. {
  100. label: "状态",
  101. prop: "status",
  102. overHidden: true
  103. },
  104. {
  105. label: "备注",
  106. prop: "remarks",
  107. overHidden: true
  108. }
  109. ]
  110. },
  111. data: [],
  112. };
  113. },
  114. components: {
  115. detailsPage,
  116. },
  117. async created() {
  118. this.option = await this.getColumnData(this.getColumnName(442), this.optionBack);
  119. },
  120. activated() {
  121. this.$nextTick(() => {
  122. this.$refs.crud.doLayout();
  123. this.$refs.crud.dicInit();
  124. });
  125. },
  126. methods: {
  127. addButton() {
  128. this.isShow = false
  129. },
  130. rowEdit(row) {
  131. this.detailData = {
  132. id: row.id
  133. };
  134. this.isShow = false
  135. },
  136. rowDel(row) {
  137. if (row.status != '已生成') {
  138. this.$confirm("确定将选择数据删除?", {
  139. confirmButtonText: "确定",
  140. cancelButtonText: "取消",
  141. type: "warning"
  142. })
  143. .then(() => {
  144. return remove({ ids: row.id }).then(() => {
  145. this.onLoad(this.page);
  146. this.$message({
  147. type: "success",
  148. message: "删除成功!"
  149. });
  150. });
  151. })
  152. } else {
  153. this.$message({
  154. message: '非禁用状态无法删除',
  155. type: 'warning'
  156. });
  157. }
  158. },
  159. // 编辑
  160. inEdit(row) {
  161. if (row.$cellEdit == true) {
  162. this.loading = true;
  163. submit(row).then(res => {
  164. this.$message({
  165. type: "success",
  166. message: "修改成功!"
  167. });
  168. this.onLoad(this.page, this.query);
  169. }).finally(() => {
  170. this.loading = false;
  171. })
  172. this.$set(row, '$cellEdit', false)
  173. } else {
  174. this.$set(row, '$cellEdit', true)
  175. }
  176. },
  177. searchReset() {
  178. this.query = this.$options.data().query;
  179. this.onLoad(this.page);
  180. },
  181. // 搜索按钮点击
  182. searchChange(params, done) {
  183. this.page.currentPage = 1;
  184. this.onLoad(this.page, this.query);
  185. done();
  186. },
  187. selectionChange(list) {
  188. this.selectionList = list;
  189. },
  190. currentChange(currentPage) {
  191. this.page.currentPage = currentPage;
  192. },
  193. sizeChange(pageSize) {
  194. this.page.pageSize = pageSize;
  195. },
  196. refreshChange() {
  197. this.onLoad(this.page, this.query);
  198. },
  199. onLoad(page, params = {}) {
  200. let obj = {}
  201. obj = {
  202. ...Object.assign(params, this.query),
  203. }
  204. this.loading = true;
  205. getList(page.currentPage, page.pageSize, obj).then(res => {
  206. this.data = res.data.data.records;
  207. this.page.total = res.data.data.total;
  208. this.$nextTick(() => {
  209. this.$refs.crud.doLayout();
  210. this.$refs.crud.dicInit();
  211. });
  212. }).finally(() => {
  213. this.loading = false;
  214. })
  215. },
  216. // 详情的返回列表
  217. goBack() {
  218. // 初始化数据
  219. // if (JSON.stringify(this.$route.query) != "{}") {
  220. // this.$router.$avueRouter.closeTag();
  221. // this.$router.push({
  222. // path: "/iosBasicData/accounts/index"
  223. // });
  224. // }
  225. this.detailData = {}
  226. this.isShow = true;
  227. this.onLoad(this.page, this.search);
  228. },
  229. //自定义列保存
  230. async saveColumn(ref, option, optionBack, code) {
  231. /**
  232. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  233. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  234. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  235. */
  236. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  237. if (inSave) {
  238. this.$message.success("保存成功");
  239. //关闭窗口
  240. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  241. this.searchReset()
  242. }
  243. },
  244. //自定义列重置
  245. async resetColumn(ref, option, optionBack, code) {
  246. this[option] = this[optionBack];
  247. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  248. if (inSave) {
  249. this.$message.success("重置成功");
  250. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  251. this.searchReset()
  252. }
  253. },
  254. // 更改表格颜色
  255. headerClassName(tab) {
  256. //颜色间隔
  257. let back = ""
  258. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  259. if (tab.columnIndex % 2 === 0) {
  260. back = "back-one"
  261. } else if (tab.columnIndex % 2 === 1) {
  262. back = "back-two"
  263. }
  264. }
  265. return back;
  266. },
  267. }
  268. }
  269. </script>
  270. <style scoped>
  271. ::v-deep#out-table .back-one {
  272. background: #ecf5ff !important;
  273. text-align: center;
  274. }
  275. ::v-deep#out-table .back-two {
  276. background: #ecf5ff !important;
  277. text-align: center;
  278. }
  279. .pointerClick {
  280. cursor: pointer;
  281. color: #1e9fff;
  282. }
  283. ::v-deep .el-col-md-8 {
  284. width: 24.33333%;
  285. }
  286. </style>