index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. :table-loading="loading"
  12. :cell-style="cellStyle"
  13. @selection-change="selectionChange"
  14. @search-change="searchChange"
  15. @current-change="currentChange"
  16. @size-change="sizeChange"
  17. @refresh-change="refreshChange"
  18. @on-load="onLoad"
  19. @search-criteria-switch="searchCriteriaSwitch"
  20. @saveColumn="saveColumn"
  21. @resetColumn="resetColumn"
  22. >
  23. <template slot-scope="scope" slot="menu">
  24. <el-button
  25. type="text"
  26. icon="el-icon-edit"
  27. size="small"
  28. @click.stop="beforeOpenPage(scope.row, scope.index)"
  29. >查看</el-button>
  30. <el-button
  31. type="text"
  32. icon="el-icon-delete"
  33. size="small"
  34. @click.stop="rowDel(scope.row, scope.index)"
  35. :disabled="scope.row.status == 4"
  36. >删除
  37. </el-button>
  38. </template>
  39. <template slot="stockUserNameSearch">
  40. <el-select
  41. v-model="search.stockUser"
  42. filterable
  43. clearable
  44. size="small"
  45. >
  46. <el-option
  47. v-for="(item,index) in userList"
  48. :key="index"
  49. :label="item.realName"
  50. :value="item.id"
  51. ></el-option>
  52. </el-select>
  53. </template>
  54. </avue-crud>
  55. </basic-container>
  56. <detail-page
  57. @goBack="goBack"
  58. @copyOrder="copyOrder"
  59. :detailData="detailData"
  60. v-if="!show"
  61. />
  62. </div>
  63. </template>
  64. <script>
  65. import option from "./config/mainList.json";
  66. import detailPage from "./detail";
  67. import {getList, deleteList} from "@/api/officeSupplies/warehousing";
  68. import { gainUser } from "@/api/basicData/customerInquiry";
  69. export default {
  70. name: "index",
  71. components: {
  72. detailPage,
  73. },
  74. data() {
  75. return {
  76. option: {},
  77. dataList: [],
  78. form: {},
  79. page: {
  80. pageSize: 10,
  81. currentPage: 1,
  82. total: 0,
  83. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  84. },
  85. search: {},
  86. show: true,
  87. loading: false,
  88. selection: [],
  89. detailData: {},
  90. userList: [],
  91. }
  92. },
  93. async created() {
  94. this.option = await this.getColumnData(this.getColumnName(97), option);
  95. gainUser().then(res => {
  96. this.userList = res.data.data;
  97. });
  98. let i = 0;
  99. this.option.column.forEach(item => {
  100. if (item.search) i++
  101. })
  102. if (i % 3 !== 0){
  103. const num = 3 - Number(i % 3)
  104. this.option.searchMenuSpan = num * 8;
  105. this.option.searchMenuPosition = "right";
  106. }
  107. },
  108. methods: {
  109. searchCriteriaSwitch(type) {
  110. if (type){
  111. this.option.height = this.option.height - 90
  112. }else {
  113. this.option.height = this.option.height + 90
  114. }
  115. this.$refs.crud.getTableHeight()
  116. },
  117. newAdd() {
  118. this.show = false;
  119. },
  120. onLoad(page, params) {
  121. // 重置掉展开
  122. this.dataList.forEach(item => {
  123. this.$refs.crud.toggleRowExpansion(item, false)
  124. })
  125. let queryParams = Object.assign({}, params, {
  126. size: page.pageSize,
  127. current: page.currentPage,
  128. tradeType: 'ORK',
  129. })
  130. if (queryParams.stockTime && queryParams.stockTime.length > 0) {
  131. queryParams = {
  132. ...queryParams,
  133. beginStockTime: queryParams.stockTime[0] + ' 00:00:00',
  134. endStockTime: queryParams.stockTime[1] + ' 23:59:59',
  135. }
  136. }
  137. delete queryParams.stockTime;
  138. this.loading = true;
  139. getList(queryParams).then(res => {
  140. this.dataList = res.data.data.records;
  141. this.page.total = res.data.data.total;
  142. this.option.height = window.innerHeight - 240;
  143. this.$nextTick(() => {
  144. this.$refs.crud.doLayout()
  145. })
  146. }).finally(() => {
  147. this.loading = false;
  148. })
  149. },
  150. async saveColumn() {
  151. const inSave = await this.saveColumnData(
  152. this.getColumnName(97),
  153. this.option
  154. );
  155. if (inSave) {
  156. this.$message.success("保存成功");
  157. //关闭窗口
  158. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  159. this.$nextTick(() => {
  160. this.$refs.crud.doLayout()
  161. })
  162. }
  163. },
  164. async resetColumn() {
  165. this.option = option;
  166. const inSave = await this.delColumnData(this.getColumnName(97), option);
  167. if (inSave) {
  168. this.$nextTick(() => {
  169. this.$refs.crud.doLayout()
  170. })
  171. this.$message.success("重置成功");
  172. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  173. }
  174. },
  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. cellStyle() {
  191. return "padding:0;height:40px;";
  192. },
  193. copyDoc() {},
  194. selectionChange(list) {
  195. this.selection = list;
  196. },
  197. goBack() {
  198. if (this.$route.query) {
  199. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  200. this.$router.push({
  201. path: "/workManagement/warehousing/index"
  202. });
  203. }
  204. this.detailData = this.$options.data().detailData;
  205. this.show = true;
  206. this.onLoad(this.page, this.search);
  207. },
  208. copyOrder(id) {
  209. this.show = true;
  210. this.detailData = {
  211. id: id,
  212. status: "copy"
  213. };
  214. this.$nextTick(() => {
  215. this.show = false;
  216. });
  217. },
  218. //删除列表后面的删除按钮触发触发(row, index, done)
  219. rowDel(row, index, done) {
  220. this.$confirm("确定删除数据?", {
  221. confirmButtonText: "确定",
  222. cancelButtonText: "取消",
  223. type: "warning"
  224. }).then(res => {
  225. return deleteList(row.id)
  226. }).then(() => {
  227. this.dataList.splice(row.$index, 1)
  228. this.$message({
  229. type: "success",
  230. message: "删除成功!"
  231. });
  232. this.page.currentPage = 1;
  233. this.onLoad(this.page)
  234. })
  235. },
  236. // 详情打开
  237. beforeOpenPage(row, index) {
  238. this.show = false;
  239. this.detailData = {
  240. id: row.id,
  241. query: true, // 表示只是查询
  242. };
  243. },
  244. },
  245. }
  246. </script>
  247. <style scoped>
  248. </style>