index.vue 8.3 KB

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