index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <basic-container v-if="show">
  3. <avue-crud :option="option"
  4. :data="dataList"
  5. ref="crud"
  6. v-model="form"
  7. :page.sync="page"
  8. @row-del="rowDel"
  9. @row-update="rowUpdate"
  10. :before-open="beforeOpen"
  11. :before-close="beforeClose"
  12. @row-save="rowSave"
  13. @search-change="searchChange"
  14. @search-reset="searchReset"
  15. @selection-change="selectionChange"
  16. @current-change="currentChange"
  17. @size-change="sizeChange"
  18. @refresh-change="refreshChange"
  19. @on-load="onLoad"
  20. @expand-change="expandChange"
  21. @saveColumn="saveColumn">
  22. <template slot-scope="{row,size}" slot="search">
  23. </template>
  24. <template slot-scope="scope" slot="expand">
  25. <el-table :data="scope.row.insideList" v-loading="scope.row.loading">
  26. <el-table-column align="center" width="60"></el-table-column>
  27. <el-table-column type="selection" align="center" width="50"></el-table-column>
  28. <el-table-column label="序号" type="index" align="center" width="50"></el-table-column>
  29. <el-table-column label="提单号" prop="billNO" align="center" show-overflow-tooltip width="150"></el-table-column>
  30. <el-table-column label="货物名称" prop="cname" align="center" show-overflow-tooltip width="150"></el-table-column>
  31. <el-table-column label="件数" prop="actualQuantity" align="center" show-overflow-tooltip width="120"></el-table-column>
  32. <el-table-column label="销售价格" prop="price" align="center" show-overflow-tooltip width="150"></el-table-column>
  33. <el-table-column label="销售数量" prop="actualQuantity" align="center" show-overflow-tooltip width="120"></el-table-column>
  34. <el-table-column label="码单数量" prop="billWeight" align="center" show-overflow-tooltip width="120"></el-table-column>
  35. <el-table-column label="是否发货" prop="isSend" align="center" show-overflow-tooltip width="120"></el-table-column>
  36. <el-table-column label="付款金额" prop="amount" align="center" show-overflow-tooltip width="150"></el-table-column>
  37. </el-table>
  38. </template>
  39. <template slot="menuLeft">
  40. <el-button size="small"
  41. type="success"
  42. :disabled="true"
  43. @click.stop=""
  44. >复制新单
  45. </el-button>
  46. <el-button size="small"
  47. type="info"
  48. @click.stop=""
  49. >报表
  50. </el-button>
  51. </template>
  52. <template slot-scope="scope" slot="menu">
  53. <el-button
  54. type="text"
  55. icon="el-icon-view"
  56. size="small"
  57. @click.stop="beforeOpenPage(scope.row,1)"
  58. >查看
  59. </el-button>
  60. <el-button
  61. type="text"
  62. icon="el-icon-edit"
  63. size="small"
  64. @click.stop="editOpen(scope.row,2)"
  65. >编辑
  66. </el-button>
  67. <el-button
  68. type="text"
  69. icon="el-icon-delete"
  70. size="small"
  71. @click.stop="rowDel(scope.row,scope.index)"
  72. >删除
  73. </el-button>
  74. </template>
  75. </avue-crud>
  76. </basic-container>
  77. <detail-page
  78. ref="detail"
  79. @goBack="goBack"
  80. :detailData="detailData"
  81. v-else
  82. ></detail-page>
  83. </template>
  84. <script>
  85. import option from "./config/mainList.json";
  86. import {selectSaleList,removeList,detailSaleList} from "@/api/importTrade/salesContract"
  87. import detailPage from "./detailsPage.vue";
  88. export default {
  89. name: "index",
  90. data() {
  91. return {
  92. option: option,
  93. dataList: [],
  94. show:true,
  95. page: {
  96. pageSize: 10,
  97. pagerCount: 5,
  98. total: 0,
  99. },
  100. form: {},
  101. detailData:{},
  102. search: {},
  103. }
  104. },
  105. components:{
  106. detailPage
  107. },
  108. async created() {
  109. // this.option = await this.getColumnData(this.getColumnName(38), option);
  110. },
  111. methods: {
  112. //删除列表后面的删除按钮触发触发(row, index, done)
  113. rowDel(row, index, done) {
  114. this.$confirm("确定将选择数据删除?", {
  115. confirmButtonText: "确定",
  116. cancelButtonText: "取消",
  117. type: "warning"
  118. }).then(() => {
  119. return removeList(row.id);
  120. }).then(() => {
  121. this.$message({
  122. type: "success",
  123. message: "操作成功!"
  124. });
  125. this.page.currentPage = 1;
  126. this.onLoad(this.page);
  127. });
  128. },
  129. //修改时的修改按钮点击触发
  130. rowUpdate(row, index, done, loading) {
  131. typeSave(row).then(() => {
  132. this.$message({
  133. type: "success",
  134. message: "操作成功!"
  135. });
  136. // 数据回调进行刷新
  137. done(row);
  138. }, error => {
  139. window.console.log(error);
  140. loading();
  141. });
  142. },
  143. //新增修改时保存触发
  144. rowSave(row, done, loading) {
  145. typeSave(row).then(res => {
  146. console.log(res)
  147. done()
  148. })
  149. },
  150. //查询全部
  151. initData() {
  152. customerList().then(res => {
  153. console.log(this.form);
  154. const column = this.findObject(this.option.column, "parentId");
  155. column.dicData = res.data.data.records;
  156. });
  157. },
  158. //新增子项触发
  159. handleAdd(row) {
  160. this.parentId = row.id;
  161. const column = this.findObject(this.option.column, "parentId");
  162. column.value = row.id;
  163. column.addDisabled = true;
  164. this.$refs.crud.rowAdd();
  165. },
  166. //查看跳转页面
  167. beforeOpenPage(row, index) {
  168. this.detailData = {
  169. id: row.id,
  170. status: status
  171. };
  172. this.show = false;
  173. },
  174. //新增跳转页面
  175. beforeOpen(row, status) {
  176. this.detailData = {
  177. id: row.id,
  178. status: status
  179. };
  180. this.show = false;
  181. },
  182. editOpen(row, status) {
  183. this.detailData = {
  184. id: row.id,
  185. status: status
  186. };
  187. this.show = false;
  188. },
  189. //点击新增时触发
  190. beforeClose(done) {
  191. this.parentId = "";
  192. const column = this.findObject(this.option.column, "parentId");
  193. column.value = "";
  194. column.addDisabled = false;
  195. done();
  196. },
  197. //点击搜索按钮触发
  198. searchChange(params, done) {
  199. console.log(params)
  200. this.page.currentPage = 1;
  201. this.onLoad(this.page, params);
  202. done()
  203. },
  204. searchReset() {
  205. console.log('1')
  206. },
  207. selectionChange() {
  208. console.log('1')
  209. },
  210. currentChange() {
  211. console.log('1')
  212. },
  213. sizeChange() {
  214. console.log('1')
  215. },
  216. refreshChange() {
  217. this.onLoad(this.page)
  218. },
  219. onLoad(page, params) {
  220. let queryParams = Object.assign({}, params, {
  221. size: page.pageSize,
  222. current: page.currentPage,
  223. })
  224. selectSaleList(queryParams).then(res => {
  225. this.dataList = res.data.data.records
  226. this.page.total = res.data.data.total
  227. if (this.page.total) {
  228. this.option.height = window.innerHeight - 350;
  229. } else {
  230. this.option.height = window.innerHeight - 305;
  231. }
  232. this.dataList.forEach(item => {
  233. this.$set(item,'insideList',[])
  234. this.$set(item,'loading', true)
  235. })
  236. })
  237. },
  238. //表格展开触发
  239. expandChange(row, expendList) {
  240. if (row.loading == true) {
  241. detailSaleList(row.id).then(res => {
  242. row.insideList = res.data.data.orderItemsList
  243. row.loading = false;
  244. })
  245. }
  246. },
  247. goBack() {
  248. this.detailData=this.$options.data().detailData
  249. this.show = true;
  250. },
  251. //列保存触发
  252. async saveColumn() {
  253. const inSave = await this.saveColumnData(
  254. this.getColumnName(38),
  255. this.option
  256. );
  257. if (inSave) {
  258. this.$message.success("保存成功");
  259. //关闭窗口
  260. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  261. }
  262. },
  263. },
  264. }
  265. </script>
  266. <style scoped>
  267. ::v-deep .el-table__expanded-cell{
  268. padding: 0 !important;
  269. }
  270. </style>