index.vue 8.6 KB

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