index.vue 6.9 KB

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