index.vue 7.8 KB

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