index.vue 11 KB

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