index.vue 6.8 KB

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