index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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="userNameSearch">
  55. <el-select
  56. v-model="search.userId"
  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. <template slot-scope="scope" slot="userName">
  70. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.userName }}</span>
  71. </template>
  72. <template slot="serialNo" slot-scope="scope">
  73. <span style="color: #409EFF;cursor: pointer" @click.stop="beforeOpenPage(scope.row,scope.index)">{{ scope.row.serialNo }}</span>
  74. </template>
  75. </avue-crud>
  76. </basic-container>
  77. <detail-page
  78. @goBack="goBack"
  79. @copyOrder="copyOrder"
  80. :detailData="detailData"
  81. v-if="!show"
  82. />
  83. </div>
  84. </template>
  85. <script>
  86. import option from "./config/mainList.json";
  87. import detailPage from "./detail";
  88. import { gainUser } from "@/api/basicData/customerInquiry";
  89. import {getList, deleteList} from "@/api/standAlone/reimbursement";
  90. export default {
  91. name: "index",
  92. components: {
  93. detailPage,
  94. },
  95. data() {
  96. return {
  97. option: {},
  98. dataList: [],
  99. form: {},
  100. page: {
  101. pageSize: 10,
  102. currentPage: 1,
  103. total: 0,
  104. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  105. },
  106. search: {},
  107. show: true,
  108. loading: false,
  109. selection: [],
  110. detailData: {},
  111. userOption: [],
  112. }
  113. },
  114. async created() {
  115. this.option = await this.getColumnData(this.getColumnName(106), option);
  116. gainUser().then(res => {
  117. this.userOption = res.data.data;
  118. })
  119. let i = 0;
  120. this.option.column.forEach(item => {
  121. if (item.search) i++
  122. })
  123. if (i % 3 !== 0){
  124. const num = 3 - Number(i % 3)
  125. this.option.searchMenuSpan = num * 8;
  126. this.option.searchMenuPosition = "right";
  127. }
  128. },
  129. activated() {
  130. if (this.$route.query.check) {
  131. this.show = true
  132. this.detailData = {
  133. id: this.$route.query.check.billId,
  134. check: this.$route.query.check,
  135. auditId: this.$route.query.check.id,
  136. };
  137. this.show = false;
  138. this.$store.commit("BX_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("BX_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. })
  163. if (queryParams.claimDate && queryParams.claimDate.length > 0) {
  164. queryParams = {
  165. ...queryParams,
  166. beginClaimDate: queryParams.claimDate[0] + ' 00:00:00',
  167. endClaimDate: queryParams.claimDate[1] + ' 23:59:59',
  168. }
  169. }
  170. delete queryParams.claimDate;
  171. this.loading = true;
  172. getList(queryParams).then(res => {
  173. this.dataList = res.data.data.records;
  174. this.page.total = res.data.data.total;
  175. this.option.height = window.innerHeight - 240;
  176. this.$nextTick(() => {
  177. this.$refs.crud.doLayout()
  178. })
  179. }).finally(() => {
  180. this.loading = false;
  181. })
  182. },
  183. async saveColumn() {
  184. const inSave = await this.saveColumnData(
  185. this.getColumnName(106),
  186. this.option
  187. );
  188. if (inSave) {
  189. this.$message.success("保存成功");
  190. //关闭窗口
  191. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  192. this.$nextTick(() => {
  193. this.$refs.crud.doLayout()
  194. })
  195. }
  196. },
  197. async resetColumn() {
  198. this.option = option;
  199. const inSave = await this.delColumnData(this.getColumnName(106), option);
  200. if (inSave) {
  201. this.$nextTick(() => {
  202. this.$refs.crud.doLayout()
  203. })
  204. this.$message.success("重置成功");
  205. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  206. }
  207. },
  208. //点击搜索按钮触发
  209. searchChange(params, done) {
  210. this.onLoad(this.page, params);
  211. done();
  212. },
  213. currentChange(val) {
  214. this.page.currentPage = val;
  215. },
  216. sizeChange(val) {
  217. this.page.currentPage = 1;
  218. this.page.pageSize = val;
  219. },
  220. refreshChange() {
  221. this.onLoad(this.page, this.search);
  222. },
  223. cellStyle() {
  224. return "padding:0;height:40px;";
  225. },
  226. copyDoc() {},
  227. selectionChange(list) {
  228. this.selection = list;
  229. },
  230. goBack() {
  231. if (this.$route.query) {
  232. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  233. this.$router.push({
  234. path: "/reimbursement/index"
  235. });
  236. }
  237. this.detailData = this.$options.data().detailData;
  238. this.show = true;
  239. this.onLoad(this.page, this.search);
  240. },
  241. copyOrder(id) {
  242. this.show = true;
  243. this.detailData = {
  244. id: id,
  245. status: "copy"
  246. };
  247. this.$nextTick(() => {
  248. this.show = false;
  249. this.$store.commit("BX_IN_DETAIL");
  250. });
  251. },
  252. // 详情打开
  253. beforeOpenPage(row, index) {
  254. this.show = false;
  255. this.detailData = {
  256. id: row.id,
  257. query: true, // 表示只是查询
  258. };
  259. this.$store.commit("BX_IN_DETAIL");
  260. },
  261. //删除列表后面的删除按钮触发触发(row, index, done)
  262. rowDel(row, index, done) {
  263. this.$confirm("确定删除数据?", {
  264. confirmButtonText: "确定",
  265. cancelButtonText: "取消",
  266. type: "warning"
  267. }).then(res => {
  268. return deleteList(row.id)
  269. }).then(() => {
  270. this.dataList.splice(row.$index, 1)
  271. this.$message({
  272. type: "success",
  273. message: "删除成功!"
  274. });
  275. this.page.currentPage = 1;
  276. this.onLoad(this.page)
  277. })
  278. },
  279. },
  280. }
  281. </script>
  282. <style scoped>
  283. </style>