index.vue 6.5 KB

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