index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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="menuLeft">
  24. <el-button
  25. type="primary"
  26. icon="el-icon-plus"
  27. size="small"
  28. @click.stop="newAdd()"
  29. >创建单据</el-button>
  30. <el-button
  31. type="success"
  32. size="small"
  33. icon="el-icon-plus"
  34. @click.stop="copyDoc()"
  35. :disabled="selection.length != 1"
  36. v-if="false"
  37. >复制单据</el-button>
  38. </template>
  39. <template slot-scope="scope" slot="menu">
  40. <el-button
  41. type="text"
  42. icon="el-icon-delete"
  43. size="small"
  44. @click.stop="rowDel(scope.row, scope.index)"
  45. :disabled="scope.row.status == 3"
  46. >删除
  47. </el-button>
  48. </template>
  49. <template slot="applyUserNameSearch">
  50. <el-select
  51. v-model="search.applyUser"
  52. filterable
  53. clearable
  54. size="small"
  55. >
  56. <el-option
  57. v-for="(item,index) in userList"
  58. :key="index"
  59. :label="item.realName"
  60. :value="item.id"
  61. ></el-option>
  62. </el-select>
  63. </template>
  64. <template slot="applyUserName" slot-scope="scope">
  65. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.applyUserName }}</span>
  66. </template>
  67. </avue-crud>
  68. </basic-container>
  69. <detail-page
  70. @goBack="goBack"
  71. @copyOrder="copyOrder"
  72. :detailData="detailData"
  73. v-if="!show"
  74. />
  75. </div>
  76. </template>
  77. <script>
  78. import option from "./config/mainList.json";
  79. import detailPage from "./detail";
  80. import { gainUser } from "@/api/basicData/customerInquiry";
  81. import {getList, deleteList} from "@/api/officeSupplies/requisition";
  82. export default {
  83. name: "index",
  84. components: {
  85. detailPage,
  86. },
  87. data() {
  88. return {
  89. option: {},
  90. dataList: [],
  91. form: {},
  92. page: {
  93. pageSize: 10,
  94. currentPage: 1,
  95. total: 0,
  96. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  97. },
  98. search: {},
  99. show: true,
  100. loading: false,
  101. selection: [],
  102. detailData: {},
  103. userList: [],
  104. }
  105. },
  106. async created() {
  107. this.option = await this.getColumnData(this.getColumnName(94), option);
  108. let i = 0;
  109. this.option.column.forEach(item => {
  110. if (item.search) i++
  111. })
  112. gainUser().then(res => {
  113. this.userList = res.data.data;
  114. });
  115. if (i % 3 !== 0){
  116. const num = 3 - Number(i % 3)
  117. this.option.searchMenuSpan = num * 8;
  118. this.option.searchMenuPosition = "right";
  119. }
  120. },
  121. activated() {
  122. if (this.$route.query.check) {
  123. this.show = true
  124. this.detailData = {
  125. id: this.$route.query.check.billId,
  126. check: this.$route.query.check,
  127. auditId: this.$route.query.check.id,
  128. };
  129. this.show = false;
  130. this.$store.commit("OFFICELY_IN_DETAIL");
  131. }
  132. if (this.$route.query.params) {
  133. this.show = true;
  134. this.detailData = {
  135. id: this.$route.query.params,
  136. };
  137. this.show = false;
  138. this.$store.commit("OFFICELY_IN_DETAIL");
  139. }
  140. },
  141. methods: {
  142. searchCriteriaSwitch(type) {
  143. if (type){
  144. this.option.height = this.option.height - 90
  145. }else {
  146. this.option.height = this.option.height + 90
  147. }
  148. this.$refs.crud.getTableHeight()
  149. },
  150. newAdd() {
  151. this.show = false;
  152. this.$store.commit("OFFICELY_IN_DETAIL");
  153. },
  154. onLoad(page, params) {
  155. // 重置掉展开
  156. this.dataList.forEach(item => {
  157. this.$refs.crud.toggleRowExpansion(item, false)
  158. })
  159. let queryParams = Object.assign({}, params, {
  160. size: page.pageSize,
  161. current: page.currentPage,
  162. tradeType: 'OLY',
  163. })
  164. if (queryParams.applyTime && queryParams.applyTime.length > 0) {
  165. queryParams = {
  166. ...queryParams,
  167. beginApplyTime: queryParams.applyTime[0] + ' 00:00:00',
  168. endApplyTime: queryParams.applyTime[1] + ' 23:59:59',
  169. }
  170. }
  171. delete queryParams.applyTime;
  172. this.loading = true;
  173. getList(queryParams).then(res => {
  174. this.dataList = res.data.data.records;
  175. this.page.total = res.data.data.total;
  176. this.option.height = window.innerHeight - 240;
  177. this.$nextTick(() => {
  178. this.$refs.crud.doLayout()
  179. })
  180. }).finally(() => {
  181. this.loading = false;
  182. })
  183. },
  184. async saveColumn() {
  185. const inSave = await this.saveColumnData(
  186. this.getColumnName(94),
  187. this.option
  188. );
  189. if (inSave) {
  190. this.$message.success("保存成功");
  191. //关闭窗口
  192. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  193. this.$nextTick(() => {
  194. this.$refs.crud.doLayout()
  195. })
  196. }
  197. },
  198. async resetColumn() {
  199. this.option = option;
  200. const inSave = await this.delColumnData(this.getColumnName(94), option);
  201. if (inSave) {
  202. this.$nextTick(() => {
  203. this.$refs.crud.doLayout()
  204. })
  205. this.$message.success("重置成功");
  206. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  207. }
  208. },
  209. //点击搜索按钮触发
  210. searchChange(params, done) {
  211. this.onLoad(this.page, params);
  212. done();
  213. },
  214. currentChange(val) {
  215. this.page.currentPage = val;
  216. },
  217. sizeChange(val) {
  218. this.page.currentPage = 1;
  219. this.page.pageSize = val;
  220. },
  221. refreshChange() {
  222. this.onLoad(this.page, this.search);
  223. },
  224. cellStyle() {
  225. return "padding:0;height:40px;";
  226. },
  227. copyDoc() {
  228. },
  229. selectionChange(list) {
  230. this.selection = list;
  231. },
  232. goBack() {
  233. if (this.$route.query.check || this.$route.query.params) {
  234. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  235. this.$router.push({
  236. path: "/workManagement/requisition/index"
  237. });
  238. }
  239. this.detailData = this.$options.data().detailData;
  240. this.show = true;
  241. this.onLoad(this.page, this.search);
  242. },
  243. copyOrder(id) {
  244. this.show = true;
  245. this.detailData = {
  246. id: id,
  247. status: "copy"
  248. };
  249. this.$nextTick(() => {
  250. this.show = false;
  251. });
  252. this.$store.commit("OFFICELY_IN_DETAIL");
  253. },
  254. //删除列表后面的删除按钮触发触发(row, index, done)
  255. rowDel(row, index, done) {
  256. this.$confirm("确定删除数据?", {
  257. confirmButtonText: "确定",
  258. cancelButtonText: "取消",
  259. type: "warning"
  260. }).then(res => {
  261. return deleteList(row.id)
  262. }).then(() => {
  263. this.dataList.splice(row.$index, 1)
  264. this.$message({
  265. type: "success",
  266. message: "删除成功!"
  267. });
  268. this.page.currentPage = 1;
  269. this.onLoad(this.page)
  270. })
  271. },
  272. // 详情打开
  273. beforeOpenPage(row, index) {
  274. this.show = false;
  275. this.detailData = {
  276. id: row.id,
  277. query: true, // 表示只是查询
  278. };
  279. this.$store.commit("OFFICELY_IN_DETAIL");
  280. },
  281. },
  282. }
  283. </script>
  284. <style scoped>
  285. </style>