index.vue 7.5 KB

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