index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. @saveColumn="saveColumn">
  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="200"></el-table-column>
  30. <el-table-column label="货物品种" prop="priceCategoryNames" align="center" show-overflow-tooltip width="180"></el-table-column>
  31. <el-table-column label="件数" prop="purchaseQuantity" align="center" show-overflow-tooltip width="120"></el-table-column>
  32. <el-table-column label="毛重(KG)" prop="grossWeight" align="center" show-overflow-tooltip width="120"></el-table-column>
  33. <el-table-column label="净重(KG)" prop="netWeight" align="center" show-overflow-tooltip width="120"></el-table-column>
  34. <el-table-column label="单价" prop="price" align="center" show-overflow-tooltip width="120"></el-table-column>
  35. <el-table-column label="合同金额" prop="amount" align="center" show-overflow-tooltip width="180"></el-table-column>
  36. <el-table-column label="是否到货" prop="isArrival" align="center" show-overflow-tooltip width="200"></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="openReport()"
  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. </div>
  84. </template>
  85. <script>
  86. import option from "./config/mainList.json";
  87. import {selectPurchaseList,removeData,getItemByPid} from "@/api/importTrade/purchase";
  88. import detailPage from "./detailsPage.vue";
  89. export default {
  90. name: "index",
  91. data() {
  92. return {
  93. loading:false,
  94. option: {},
  95. detailData:{},
  96. dataList: [],
  97. page: {
  98. pageSize: 10,
  99. pagerCount: 5,
  100. total: 0,
  101. },
  102. form: {},
  103. show: true,
  104. search: {},
  105. }
  106. },
  107. components:{
  108. detailPage
  109. },
  110. async created() {
  111. this.option = await this.getColumnData(this.getColumnName(36), option);
  112. },
  113. methods: {
  114. //删除列表后面的删除按钮触发触发(row, index, done)
  115. rowDel(row, index, done) {
  116. this.$confirm("确定将选择数据删除?", {
  117. confirmButtonText: "确定",
  118. cancelButtonText: "取消",
  119. type: "warning"
  120. }).then(() => {
  121. removeData(row.id).then(res =>{
  122. if(res.data.success){
  123. this.$message({
  124. type: "success",
  125. message: "操作成功!"
  126. });
  127. this.onLoad(this.page );
  128. }
  129. })
  130. })
  131. },
  132. //修改时的修改按钮点击触发
  133. rowUpdate(row, index, done, loading) {
  134. typeSave(row).then(() => {
  135. this.$message({
  136. type: "success",
  137. message: "操作成功!"
  138. });
  139. // 数据回调进行刷新
  140. done(row);
  141. }, error => {
  142. window.console.log(error);
  143. loading();
  144. });
  145. },
  146. //新增修改时保存触发
  147. rowSave(row, done, loading) {
  148. typeSave(row).then(res => {
  149. console.log(res)
  150. done()
  151. })
  152. },
  153. //查询全部
  154. initData() {
  155. customerList().then(res => {
  156. console.log(this.form);
  157. const column = this.findObject(this.option.column, "parentId");
  158. column.dicData = res.data.data.records;
  159. });
  160. },
  161. //新增子项触发
  162. handleAdd(row) {
  163. this.parentId = row.id;
  164. const column = this.findObject(this.option.column, "parentId");
  165. column.value = row.id;
  166. column.addDisabled = true;
  167. this.$refs.crud.rowAdd();
  168. },
  169. //查看跳转页面
  170. beforeOpenPage(row, status) {
  171. this.detailData = {
  172. id: row.id,
  173. status: status
  174. };
  175. this.show = false;
  176. },
  177. //新增跳转页面
  178. beforeOpen(row, status) {
  179. this.detailData = {
  180. id: row.id,
  181. status: status
  182. };
  183. this.show = false;
  184. },
  185. editOpen(row, status) {
  186. this.detailData = {
  187. id: row.id,
  188. status: status
  189. };
  190. this.show = false;
  191. },
  192. //点击新增时触发
  193. beforeClose(done) {
  194. this.parentId = "";
  195. const column = this.findObject(this.option.column, "parentId");
  196. column.value = "";
  197. column.addDisabled = false;
  198. done();
  199. },
  200. //点击搜索按钮触发
  201. searchChange(params, done) {
  202. console.log(params)
  203. this.page.currentPage = 1;
  204. this.onLoad(this.page, params);
  205. done()
  206. },
  207. searchReset() {
  208. console.log('1')
  209. },
  210. selectionChange() {
  211. console.log('1')
  212. },
  213. currentChange() {
  214. console.log('1')
  215. },
  216. sizeChange() {
  217. console.log('1')
  218. },
  219. refreshChange() {
  220. this.onLoad(this.page);
  221. },
  222. onLoad(page, params) {
  223. if(params){
  224. if (params.businesDate != undefined) {
  225. params.businesStartDate = params.businesDate[0]+ " " + "00:00:00";
  226. params.businesEndDate = params.businesDate[1] + " " + "23:59:59";
  227. this.$delete(params,'businesDate')
  228. }
  229. if (params.accountsCollectionDate!= undefined) {
  230. params.accountsCollectionStartDate = params.accountsCollectionDate[0]+ " " + "00:00:00";
  231. params.accountsCollectionEndDate = params.accountsCollectionDate[1] + " " + "23:59:59";
  232. this.$delete(params,'accountsCollectionDate')
  233. }
  234. if (params.dateOfArrival!= undefined) {
  235. params.dateOfStartArrival = params.dateOfArrival[0]+ " " + "00:00:00";
  236. params.dateOfEndArrival = params.dateOfArrival[1] + " " + "23:59:59";
  237. this.$delete(params,'dateOfArrival')
  238. }
  239. }
  240. let queryParams = Object.assign({}, params, {
  241. size: page.pageSize,
  242. current: page.currentPage,
  243. tradeType:"JK" //进口参数
  244. })
  245. this.loading = true
  246. selectPurchaseList(queryParams).then(res => {
  247. this.dataList = res.data.data.records
  248. this.page.total = res.data.data.total
  249. if (this.page.total) {
  250. this.option.height = window.innerHeight - 350;
  251. } else {
  252. this.option.height = window.innerHeight - 305;
  253. }
  254. })
  255. .finally(()=>{
  256. this.loading = false
  257. })
  258. },
  259. //表格展开触发
  260. expandChange(row, expendList) {
  261. if(row.hasItem){
  262. getItemByPid(row.id).then(res =>{
  263. this.$set(this.dataList[row.$index],"insideList", res.data.data)
  264. row.loading = false
  265. })
  266. }else{
  267. return
  268. }
  269. },
  270. goBack() {
  271. this.detailData=this.$options.data().detailData
  272. this.show = true;
  273. },
  274. //列保存触发
  275. async saveColumn() {
  276. const inSave = await this.saveColumnData(
  277. this.getColumnName(36),
  278. this.option
  279. );
  280. if (inSave) {
  281. this.$message.success("保存成功");
  282. //关闭窗口
  283. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  284. }
  285. },
  286. },
  287. }
  288. </script>
  289. <style scoped>
  290. ::v-deep .el-table__expanded-cell{
  291. padding: 0 !important;
  292. }
  293. </style>