index.vue 6.9 KB

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