index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. <template>
  2. <div>
  3. <basic-container v-show="isShow" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. :before-open="beforeOpen"
  9. :page.sync="page"
  10. :search.sync="search"
  11. :cell-style="cellStyle"
  12. @search-change="searchChange"
  13. @current-change="currentChange"
  14. @size-change="sizeChange"
  15. @refresh-change="refreshChange"
  16. @on-load="onLoad"
  17. :table-loading="loading"
  18. @saveColumn="saveColumn"
  19. @resetColumn="resetColumn"
  20. @expand-change="expandChange"
  21. >
  22. <template slot-scope="{ row }" slot="expand">
  23. <avue-crud
  24. :data="row.itemData"
  25. :option="itemOption"
  26. :table-loading="row.itemLoading"
  27. :cell-style="cellStyle"
  28. class="itemTable"
  29. ></avue-crud>
  30. </template>
  31. <template slot="corpIdSearch">
  32. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  33. </template>
  34. <template slot="businesDateSearch">
  35. <el-date-picker
  36. v-model="search.businesDate"
  37. type="daterange"
  38. start-placeholder="开始日期"
  39. end-placeholder="结束日期"
  40. format="yyyy-MM-dd"
  41. value-format="yyyy-MM-dd HH:mm:ss"
  42. :default-time="['00:00:00', '23:59:59']"
  43. >
  44. </el-date-picker>
  45. </template>
  46. <!-- <template slot-scope="{ row }" slot="corpId">
  47. <span>{{ row.corpsName }}</span>
  48. </template> -->
  49. </avue-crud>
  50. </basic-container>
  51. </div>
  52. </template>
  53. <script>
  54. import { getList, getProfitItem } from "@/api/statisticAnalysis/salesProfit";
  55. export default {
  56. name: "index",
  57. data() {
  58. return {
  59. form: {},
  60. search: {},
  61. dataList: [],
  62. loading: false,
  63. isShow: true,
  64. detailData: {},
  65. page: {
  66. pageSize: 10,
  67. currentPage: 1
  68. },
  69. option: {
  70. searchShow: true,
  71. searchMenuSpan: 24,
  72. align: "center",
  73. searchSpan: 8,
  74. border: true,
  75. index: true,
  76. addBtn: false,
  77. viewBtn: false,
  78. editBtn: false,
  79. delBtn: false,
  80. menuWidth: 120,
  81. searchLabelWidth: 100,
  82. searchIcon: true,
  83. searchIndex: 2,
  84. expand: true,
  85. expandWidth: 38,
  86. menu: false,
  87. column: [
  88. {
  89. label: "合同号",
  90. prop: "orderNo",
  91. overHidden: true,
  92. width: 100,
  93. search: true
  94. },
  95. {
  96. label: "客户名称",
  97. prop: "corpId",
  98. overHidden: true,
  99. width: 100,
  100. search: true,
  101. formatter: row => {
  102. return row.corpsName;
  103. }
  104. },
  105. {
  106. label: "合同日期",
  107. prop: "businesDate",
  108. type: "date",
  109. format: "yyyy-MM-dd",
  110. overHidden: true,
  111. search: true,
  112. width: 100
  113. },
  114. {
  115. label: "起运港",
  116. prop: "portOfLoad",
  117. overHidden: true,
  118. width: 100
  119. },
  120. {
  121. label: "目的港",
  122. prop: "portOfDestination",
  123. overHidden: true,
  124. width: 100
  125. },
  126. {
  127. label: "运输条款",
  128. prop: "transport",
  129. overHidden: true,
  130. width: 100
  131. },
  132. {
  133. label: "采购报价",
  134. prop: "purchasePrice",
  135. overHidden: true,
  136. width: 100
  137. },
  138. {
  139. label: "销售金额",
  140. prop: "amount",
  141. overHidden: true,
  142. width: 100
  143. },
  144. {
  145. label: "产品毛利",
  146. prop: "grossProfit",
  147. overHidden: true,
  148. width: 100
  149. },
  150. {
  151. label: "产品利率",
  152. prop: "grossProfitRate",
  153. overHidden: true,
  154. width: 100
  155. },
  156. {
  157. label: "费用应收",
  158. prop: "fd",
  159. overHidden: true,
  160. width: 100
  161. },
  162. {
  163. label: "费用应付",
  164. prop: "fc",
  165. overHidden: true,
  166. width: 100
  167. },
  168. {
  169. label: "单票利润",
  170. prop: "singleTicketMargin",
  171. overHidden: true,
  172. width: 100
  173. }
  174. ]
  175. },
  176. itemOption: {
  177. align: "center",
  178. header: false,
  179. menu: false,
  180. column: [
  181. {
  182. label: "产品类别",
  183. prop: "priceCategory",
  184. width: 100,
  185. overHidden: true
  186. },
  187. {
  188. label: "产品名称",
  189. prop: "cname",
  190. width: 100,
  191. overHidden: true
  192. },
  193. {
  194. label: "产品成本",
  195. prop: "purchaseAmount",
  196. width: 100,
  197. overHidden: true
  198. },
  199. {
  200. label: "原始成本",
  201. prop: "purchaseCost",
  202. width: 100,
  203. overHidden: true
  204. },
  205. {
  206. label: "配件成本",
  207. prop: "partsPrice",
  208. width: 100,
  209. overHidden: true
  210. },
  211. {
  212. label: "原始成本",
  213. prop: "partsCost",
  214. width: 100,
  215. overHidden: true
  216. },
  217. {
  218. label: "销售价",
  219. prop: "price",
  220. width: 100,
  221. overHidden: true
  222. },
  223. {
  224. label: "汇率",
  225. prop: "exchangeRate",
  226. width: 100,
  227. overHidden: true
  228. },
  229. {
  230. label: "销售金额",
  231. prop: "amount",
  232. width: 100,
  233. overHidden: true
  234. },
  235. {
  236. label: "产品毛利",
  237. prop: "productGrossMargin",
  238. width: 100,
  239. overHidden: true
  240. },
  241. {
  242. label: "产品毛利率 ",
  243. prop: "itemMargin",
  244. width: 100,
  245. overHidden: true
  246. }
  247. ]
  248. }
  249. };
  250. },
  251. methods: {
  252. cellStyle() {
  253. return "padding:0;height:40px;";
  254. },
  255. expandChange(row) {
  256. if (!row.itemData) {
  257. getProfitItem({ id: row.id })
  258. .then(res => {
  259. this.dataList[row.$index].itemData = res.data.data;
  260. })
  261. .finally(() => {
  262. this.dataList[row.$index].itemLoading = false;
  263. });
  264. }
  265. },
  266. //点击搜索按钮触发
  267. searchChange(params, done) {
  268. if (params.businesDate) {
  269. params.contractStartDate = params.businesDate[0];
  270. params.contractEndDate = params.businesDate[1];
  271. }
  272. delete params.businesDate;
  273. this.page.currentPage = 1;
  274. this.onLoad(this.page, params);
  275. done();
  276. },
  277. refreshChange() {
  278. this.onLoad(this.page, this.search);
  279. },
  280. currentChange(val) {
  281. this.page.currentPage = val;
  282. },
  283. sizeChange(val) {
  284. this.page.currentPage = 1;
  285. this.page.pageSize = val;
  286. },
  287. onLoad(page, params) {
  288. this.loading = true;
  289. this.dataList.forEach(item => {
  290. this.$refs.crud.toggleRowExpansion(item, false);
  291. });
  292. getList(page.currentPage, page.pageSize, params)
  293. .then(res => {
  294. if (res.data.data.records) {
  295. res.data.data.records.forEach(e => {
  296. e.itemLoading = true;
  297. });
  298. }
  299. this.dataList = res.data.data.records ? res.data.data.records : [];
  300. this.page.total = res.data.data.total;
  301. if (this.page.total) {
  302. this.option.height = window.innerHeight - 260;
  303. }
  304. })
  305. .finally(() => {
  306. this.loading = false;
  307. });
  308. },
  309. //新增跳转页面
  310. beforeOpen() {
  311. this.isShow = false;
  312. },
  313. editOpen(row, status) {
  314. this.detailData = {
  315. id: row.id,
  316. status: status
  317. };
  318. this.isShow = false;
  319. },
  320. goBack() {
  321. this.detailData = this.$options.data().detailData;
  322. this.isShow = true;
  323. }
  324. }
  325. };
  326. </script>
  327. <style scoped>
  328. .page-crad ::v-deep .basic-container__card {
  329. height: 94.2vh;
  330. }
  331. ::v-deep .el-table__expanded-cell[class*="cell"] {
  332. padding: 0px;
  333. }
  334. .itemTable ::v-deep .el-table {
  335. width: 100%;
  336. }
  337. </style>