index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <basic-container>
  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. <template slot-scope="scope" slot="expand">
  22. <el-table :data="scope.row.insideList" v-loading="scope.row.loading">
  23. <el-table-column align="center" width="60"></el-table-column>
  24. <el-table-column type="selection" align="center" width="50"></el-table-column>
  25. <el-table-column label="序号" type="index" align="center" width="50"></el-table-column>
  26. <el-table-column label="提单号" prop="billNO" align="center" show-overflow-tooltip width="200"></el-table-column>
  27. <el-table-column label="货物品种" prop="priceCategory" align="center" show-overflow-tooltip width="180"></el-table-column>
  28. <el-table-column label="件数" prop="purchaseQuantity" align="center" show-overflow-tooltip width="120"></el-table-column>
  29. <el-table-column label="毛重(KG)" prop="grossWeight" align="center" show-overflow-tooltip width="120"></el-table-column>
  30. <el-table-column label="净重(KG)" prop="netWeight" align="center" show-overflow-tooltip width="120"></el-table-column>
  31. <el-table-column label="单价" prop="price" align="center" show-overflow-tooltip width="120"></el-table-column>
  32. <el-table-column label="合同金额" prop="amount" align="center" show-overflow-tooltip width="180"></el-table-column>
  33. <el-table-column label="是否到货" prop="isArrival" align="center" show-overflow-tooltip width="200"></el-table-column>
  34. </el-table>
  35. </template>
  36. <template slot="menuLeft">
  37. <el-button size="small"
  38. type="success"
  39. @click.stop=""
  40. >复制新单
  41. </el-button>
  42. <el-button size="small"
  43. type="info"
  44. @click.stop="openReport()"
  45. >报表
  46. </el-button>
  47. </template>
  48. <template slot-scope="scope" slot="menu">
  49. <el-button
  50. type="text"
  51. icon="el-icon-view"
  52. size="small"
  53. @click.stop="beforeOpenPage(scope.row,scope.index)"
  54. >查看
  55. </el-button>
  56. <el-button
  57. type="text"
  58. icon="el-icon-edit"
  59. size="small"
  60. @click.stop="editOpen(scope.row,scope.index)"
  61. >编辑
  62. </el-button>
  63. <el-button
  64. type="text"
  65. icon="el-icon-delete"
  66. size="small"
  67. @click.stop="rowDel(scope.row,scope.index)"
  68. >删除
  69. </el-button>
  70. </template>
  71. </avue-crud>
  72. </basic-container>
  73. </template>
  74. <script>
  75. import option from "./config/mainList.json";
  76. import {selectPurchaseList,removeData,getItemByPid} from "@/api/importTrade/purchase";
  77. export default {
  78. name: "index",
  79. data() {
  80. return {
  81. option: option,
  82. dataList: [],
  83. page: {
  84. pageSize: 10,
  85. pagerCount: 5,
  86. total: 0,
  87. },
  88. form: {},
  89. search: {},
  90. }
  91. },
  92. methods: {
  93. //删除列表后面的删除按钮触发触发(row, index, done)
  94. rowDel(row, index, done) {
  95. this.$confirm("确定将选择数据删除?", {
  96. confirmButtonText: "确定",
  97. cancelButtonText: "取消",
  98. type: "warning"
  99. }).then(() => {
  100. removeData(row.id).then(res =>{
  101. if(res.data.success){
  102. this.$message({
  103. type: "success",
  104. message: "操作成功!"
  105. });
  106. this.onLoad(this.page );
  107. }
  108. })
  109. })
  110. },
  111. //修改时的修改按钮点击触发
  112. rowUpdate(row, index, done, loading) {
  113. typeSave(row).then(() => {
  114. this.$message({
  115. type: "success",
  116. message: "操作成功!"
  117. });
  118. // 数据回调进行刷新
  119. done(row);
  120. }, error => {
  121. window.console.log(error);
  122. loading();
  123. });
  124. },
  125. //新增修改时保存触发
  126. rowSave(row, done, loading) {
  127. typeSave(row).then(res => {
  128. console.log(res)
  129. done()
  130. })
  131. },
  132. //查询全部
  133. initData() {
  134. customerList().then(res => {
  135. console.log(this.form);
  136. const column = this.findObject(this.option.column, "parentId");
  137. column.dicData = res.data.data.records;
  138. });
  139. },
  140. //新增子项触发
  141. handleAdd(row) {
  142. this.parentId = row.id;
  143. const column = this.findObject(this.option.column, "parentId");
  144. column.value = row.id;
  145. column.addDisabled = true;
  146. this.$refs.crud.rowAdd();
  147. },
  148. //查看跳转页面
  149. beforeOpenPage(row, index) {
  150. this.$router.push({
  151. path: "/purchase_detailsPage",
  152. query: {id: JSON.stringify(row.id)},
  153. });
  154. },
  155. //新增跳转页面
  156. beforeOpen(row, index) {
  157. this.$router.push({
  158. path: "/purchase_detailsPage",
  159. query: {id: JSON.stringify(row.id)},
  160. });
  161. },
  162. editOpen(row, index) {
  163. this.$router.push({
  164. path: "/purchase_detailsPage",
  165. query: {id: JSON.stringify(row.id)},
  166. });
  167. },
  168. //点击新增时触发
  169. beforeClose(done) {
  170. this.parentId = "";
  171. const column = this.findObject(this.option.column, "parentId");
  172. column.value = "";
  173. column.addDisabled = false;
  174. done();
  175. },
  176. //点击搜索按钮触发
  177. searchChange(params, done) {
  178. console.log(params)
  179. this.page.currentPage = 1;
  180. this.onLoad(this.page, params);
  181. done()
  182. },
  183. searchReset() {
  184. console.log('1')
  185. },
  186. selectionChange() {
  187. console.log('1')
  188. },
  189. currentChange() {
  190. console.log('1')
  191. },
  192. sizeChange() {
  193. console.log('1')
  194. },
  195. refreshChange() {
  196. console.log('1')
  197. },
  198. onLoad(page, params) {
  199. console.log()
  200. if(params){
  201. if (params.businesDate != undefined) {
  202. params.businesStartDate = params.businesDate[0]+ " " + "00:00:00";
  203. params.businesEndDate = params.businesDate[1] + " " + "23:59:59";
  204. this.$delete(params,'businesDate')
  205. }
  206. if (params.accountsCollectionDate!= undefined) {
  207. params.accountsCollectionStartDate = params.accountsCollectionDate[0]+ " " + "00:00:00";
  208. params.accountsCollectionEndDate = params.accountsCollectionDate[1] + " " + "23:59:59";
  209. this.$delete(params,'accountsCollectionDate')
  210. }
  211. if (params.dateOfArrival!= undefined) {
  212. params.dateOfStartArrival = params.dateOfArrival[0]+ " " + "00:00:00";
  213. params.dateOfEndArrival = params.dateOfArrival[1] + " " + "23:59:59";
  214. this.$delete(params,'dateOfArrival')
  215. }
  216. }
  217. let queryParams = Object.assign({}, params, {
  218. size: page.pageSize,
  219. current: page.currentPage,
  220. tradeType:"JK" //进口参数
  221. })
  222. selectPurchaseList(queryParams).then(res => {
  223. this.dataList = res.data.data.records
  224. this.page.total = res.data.data.total
  225. })
  226. },
  227. //表格展开触发
  228. expandChange(row, expendList) {
  229. if(row.hasItem){
  230. getItemByPid(row.id).then(res =>{
  231. this.dataList[row.$index].insideList = res.data.data;
  232. row.loading = false
  233. })
  234. }else{
  235. return
  236. }
  237. },
  238. },
  239. }
  240. </script>
  241. <style scoped>
  242. ::v-deep .el-table__expanded-cell{
  243. padding: 0 !important;
  244. }
  245. </style>