index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud
  5. ref="crud"
  6. :option="option"
  7. :data="dataList"
  8. v-model="form"
  9. :page.sync="page"
  10. :search.sync="search"
  11. @search-change="searchChange"
  12. @current-change="currentChange"
  13. @size-change="sizeChange"
  14. @refresh-change="refreshChange"
  15. @on-load="onLoad"
  16. @saveColumn="saveColumn"
  17. @resetColumn="resetColumn"
  18. :cell-style="cellStyle"
  19. :summary-method="summaryMethod"
  20. @expand-change="expandChange"
  21. @selection-change="selectionChange"
  22. >
  23. <template slot-scope="{ row }" slot="expand">
  24. <avue-crud
  25. :data="row.itemData"
  26. :option="itemOption"
  27. :table-loading="row.itemLoading"
  28. :cell-style="cellStyle"
  29. class="itemTable"
  30. ></avue-crud>
  31. </template>
  32. <template slot-scope="{ row }" slot="grossProfitRate">
  33. {{ row.grossProfitRate }}%
  34. </template>
  35. <template slot-scope="{ row }" slot="createUser">
  36. <span>{{ row.createUserName }}</span>
  37. </template>
  38. <template slot-scope="{ row }" slot="orderQuantity">
  39. <span>{{ row.orderQuantity | IntegerFormat }}</span>
  40. </template>
  41. <template slot="menuLeft">
  42. <el-button
  43. type="primary"
  44. icon="el-icon-plus"
  45. size="small"
  46. @click.stop="newAdd('new')"
  47. >创建单据
  48. </el-button>
  49. <el-button
  50. type="success"
  51. size="small"
  52. @click.stop="copyDoc()"
  53. :disabled="selectionList.length != 1"
  54. >复制单据</el-button
  55. >
  56. <el-button type="info" size="small">报表</el-button>
  57. </template>
  58. <template slot="corpIdSearch">
  59. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  60. </template>
  61. <template slot="portOfLoadSearch">
  62. <port-info v-model="search.portOfLoad" />
  63. </template>
  64. <template slot="portOfDestinationSearch">
  65. <port-info v-model="search.portOfDestination" />
  66. </template>
  67. <template slot="businesDateSearch">
  68. <el-date-picker
  69. v-model="search.businesDate"
  70. type="daterange"
  71. start-placeholder="开始日期"
  72. end-placeholder="结束日期"
  73. format="yyyy-MM-dd"
  74. value-format="yyyy-MM-dd HH:mm:ss"
  75. :default-time="['00:00:00', '23:59:59']"
  76. >
  77. </el-date-picker>
  78. </template>
  79. <template slot="plannedDeliveryDateSearch">
  80. <el-date-picker
  81. v-model="search.plannedDeliveryDate"
  82. type="daterange"
  83. start-placeholder="开始日期"
  84. end-placeholder="结束日期"
  85. format="yyyy-MM-dd"
  86. value-format="yyyy-MM-dd HH:mm:ss"
  87. :default-time="['00:00:00', '23:59:59']"
  88. >
  89. </el-date-picker>
  90. </template>
  91. <template slot="createTimeSearch">
  92. <el-date-picker
  93. v-model="search.createTime"
  94. type="daterange"
  95. start-placeholder="开始日期"
  96. end-placeholder="结束日期"
  97. format="yyyy-MM-dd"
  98. value-format="yyyy-MM-dd HH:mm:ss"
  99. :default-time="['00:00:00', '23:59:59']"
  100. >
  101. </el-date-picker>
  102. </template>
  103. <template slot-scope="scope" slot="corpId">
  104. <span
  105. style="color: #409EFF;cursor: pointer"
  106. @click.stop="beforeOpenPage(scope.row, 1)"
  107. >{{ scope.row.corpsName }}
  108. </span>
  109. </template>
  110. <template slot-scope="scope" slot="orderNo">
  111. <span
  112. style="color: #409EFF;cursor: pointer"
  113. @click.stop="beforeOpenPage(scope.row, 1)"
  114. >{{ scope.row.orderNo }}
  115. </span>
  116. </template>
  117. <template slot-scope="scope" slot="menu">
  118. <el-button
  119. type="text"
  120. icon="el-icon-edit"
  121. size="small"
  122. @click.stop="editOpen(scope.row, 1)"
  123. >编辑
  124. </el-button>
  125. <el-button
  126. type="text"
  127. icon="el-icon-delete"
  128. size="small"
  129. @click.stop="rowDel(scope.row, scope.index)"
  130. >删除
  131. </el-button>
  132. </template>
  133. </avue-crud>
  134. </basic-container>
  135. <detail-page
  136. @goBack="goBack"
  137. @copyOrder="copyOrder"
  138. :detailData="detailData"
  139. v-if="!show"
  140. ></detail-page>
  141. </div>
  142. </template>
  143. <script>
  144. import option from "./config/mainList.json";
  145. import {
  146. getList,
  147. remove,
  148. getPorts,
  149. gainUser,
  150. getGoodsInfo
  151. } from "@/api/basicData/salesContract";
  152. import detailPage from "./detailsPage.vue";
  153. import { defaultDate } from "@/util/date";
  154. import { micrometerFormat, IntegerFormat } from "@/util/validate";
  155. import _ from "lodash";
  156. export default {
  157. name: "customerInformation",
  158. data() {
  159. return {
  160. search: {
  161. businesDate: defaultDate()
  162. },
  163. form: {},
  164. option: {},
  165. parentId: 0,
  166. dataList: [],
  167. page: {
  168. pageSize: 10,
  169. currentPage: 1,
  170. total: 0,
  171. pageSizes: [10, 50, 100, 200, 300, 400, 500]
  172. },
  173. show: true,
  174. detailData: {},
  175. loading: false,
  176. itemOption: {
  177. align: "center",
  178. header: false,
  179. menu: false,
  180. column: [
  181. {
  182. label: "产品类别",
  183. prop: "priceCategory",
  184. width: 138,
  185. overHidden: true
  186. },
  187. {
  188. label: "产品名称",
  189. prop: "cname",
  190. width: 100,
  191. overHidden: true
  192. },
  193. {
  194. label: "产品描述",
  195. prop: "itemDescription",
  196. width: 100,
  197. overHidden: true
  198. },
  199. {
  200. label: "配件描述",
  201. prop: "partsDescribe",
  202. width: 100,
  203. overHidden: true
  204. },
  205. {
  206. label: "配件价格描述",
  207. prop: "partsPriceDescribe",
  208. width: 100,
  209. overHidden: true
  210. },
  211. {
  212. label: "数量",
  213. prop: "orderQuantity",
  214. width: 100,
  215. overHidden: true
  216. },
  217. {
  218. label: "金额",
  219. prop: "amount",
  220. width: 100,
  221. overHidden: true
  222. }
  223. ]
  224. },
  225. selectionList: []
  226. };
  227. },
  228. components: { detailPage },
  229. async created() {
  230. this.option = await this.getColumnData(this.getColumnName(4), option);
  231. getPorts().then(res => {
  232. this.findObject(this.option.column, "portOfLoad").dicData = res.data;
  233. this.findObject(this.option.column, "portOfDestination").dicData =
  234. res.data;
  235. });
  236. this.getWorkDicts("order_status").then(res => {
  237. this.findObject(this.option.column, "orderStatus").dicData =
  238. res.data.data;
  239. });
  240. gainUser().then(res => {
  241. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  242. });
  243. },
  244. filters: {
  245. IntegerFormat(num) {
  246. return IntegerFormat(num);
  247. }
  248. },
  249. methods: {
  250. cellStyle() {
  251. return "padding:0;height:40px;";
  252. },
  253. selectionChange(list) {
  254. this.selectionList = list;
  255. },
  256. expandChange(row) {
  257. if (!row.itemData) {
  258. getGoodsInfo({ id: row.id, tradeType: "CK" })
  259. .then(res => {
  260. this.dataList[row.$index].itemData = res.data.data;
  261. })
  262. .finally(() => {
  263. this.dataList[row.$index].itemLoading = false;
  264. });
  265. }
  266. },
  267. //删除列表后面的删除按钮触发触发(row, index, done)
  268. rowDel(row, index, done) {
  269. this.$confirm("确定删除数据?", {
  270. confirmButtonText: "确定",
  271. cancelButtonText: "取消",
  272. type: "warning"
  273. }).then(() => {
  274. remove(row.id).then(res => {
  275. if (res.data.code == 200) {
  276. this.$message({
  277. type: "success",
  278. message: "删除成功!"
  279. });
  280. this.onLoad(this.page, this.search);
  281. }
  282. });
  283. });
  284. },
  285. //查看跳转页面
  286. beforeOpenPage(row, status) {
  287. this.detailData = {
  288. id: row.id,
  289. status: status
  290. };
  291. this.show = false;
  292. },
  293. editOpen(row, status) {
  294. this.detailData = {
  295. id: row.id,
  296. status: status
  297. };
  298. this.show = false;
  299. this.inDetailsKey(this.$route.name, {
  300. moduleName: "xs",
  301. tableName: "business_order",
  302. id: row.id
  303. });
  304. },
  305. //点击搜索按钮触发
  306. searchChange(params, done) {
  307. if (params.businesDate) {
  308. params.orderStartDate = params.businesDate[0];
  309. params.orderEndDate = params.businesDate[1];
  310. }
  311. if (params.plannedDeliveryDate) {
  312. params.plannedDeliveryStart = params.plannedDeliveryDate[0];
  313. params.plannedDeliveryEnd = params.plannedDeliveryDate[1];
  314. }
  315. if (params.createTime) {
  316. params.createTimeStart = params.createTime[0];
  317. params.createTimeEnd = params.createTime[1];
  318. }
  319. delete params.businesDate;
  320. delete params.plannedDeliveryDate;
  321. delete params.createTime;
  322. this.page.currentPage = 1;
  323. this.onLoad(this.page, params);
  324. done();
  325. },
  326. currentChange(val) {
  327. this.page.currentPage = val;
  328. },
  329. sizeChange(val) {
  330. this.page.currentPage = 1;
  331. this.page.pageSize = val;
  332. },
  333. onLoad(page, params) {
  334. if (this.search.businesDate && this.search.businesDate.length > 0) {
  335. params = {
  336. ...params,
  337. orderStartDate: this.search.businesDate[0],
  338. orderEndDate: this.search.businesDate[1]
  339. };
  340. delete params.businesDate;
  341. }
  342. this.dataList.forEach(item => {
  343. this.$refs.crud.toggleRowExpansion(item, false);
  344. });
  345. getList(page.currentPage, page.pageSize, params).then(res => {
  346. if (res.data.data.records) {
  347. res.data.data.records.forEach(e => {
  348. e.itemLoading = true;
  349. });
  350. }
  351. this.dataList = res.data.data.records ? res.data.data.records : [];
  352. this.page.total = res.data.data.total;
  353. if (this.page.total) {
  354. this.option.height = window.innerHeight - 400;
  355. }
  356. });
  357. },
  358. refreshChange() {
  359. this.onLoad(this.page, this.search);
  360. },
  361. newAdd(type) {
  362. this.detailData = {
  363. pageType: type
  364. };
  365. this.show = false;
  366. },
  367. copyDoc() {
  368. this.selectionList.forEach(e => {
  369. this.detailData = {
  370. id: e.id,
  371. status: "copy"
  372. };
  373. this.show = false;
  374. });
  375. },
  376. copyOrder(id) {
  377. this.show = true;
  378. this.detailData = {
  379. id: id,
  380. status: "copy"
  381. };
  382. this.$nextTick(() => {
  383. this.show = false;
  384. });
  385. },
  386. goBack() {
  387. this.detailData = this.$options.data().detailData;
  388. this.show = true;
  389. this.onLoad(this.page, this.search);
  390. },
  391. summaryMethod({ columns, data }) {
  392. const sums = [];
  393. if (columns.length > 0) {
  394. columns.forEach((item, index) => {
  395. sums[0] = "合计";
  396. if (
  397. item.property == "minOrder" ||
  398. item.property == "predictOceanFreight" ||
  399. item.property == "referenceOceanFreight" ||
  400. item.property == "oceanFreight" ||
  401. item.property == "orderQuantity" ||
  402. item.property == "actualQuantity" ||
  403. item.property == "grossProfit" ||
  404. item.property == "amount" ||
  405. item.property == "purchaseAmount"
  406. ) {
  407. let qtySum = 0;
  408. let instoreSum = 0;
  409. let totalSum = 0;
  410. let oceanFreightSum = 0;
  411. let orderQuantitySum = 0;
  412. let actualQuantitySum = 0;
  413. let amountSum = 0;
  414. let purchaseAmountSum = 0;
  415. data.forEach(e => {
  416. qtySum = _.add(qtySum, Number(e.minOrder));
  417. instoreSum = _.add(instoreSum, Number(e.predictOceanFreight));
  418. totalSum = _.add(totalSum, Number(e.referenceOceanFreight));
  419. oceanFreightSum = _.add(oceanFreightSum, Number(e.oceanFreight));
  420. orderQuantitySum = _.add(
  421. orderQuantitySum,
  422. Number(e.orderQuantity)
  423. );
  424. actualQuantitySum = _.add(
  425. actualQuantitySum,
  426. Number(e.actualQuantity)
  427. );
  428. amountSum = _.add(amountSum, Number(e.amount));
  429. purchaseAmountSum = _.add(
  430. purchaseAmountSum,
  431. Number(e.purchaseAmount)
  432. );
  433. });
  434. //数量总计
  435. if (item.property == "minOrder") {
  436. sums[index] = qtySum ? qtySum.toFixed(2) : "0.00";
  437. }
  438. //入库金额总计
  439. if (item.property == "predictOceanFreight") {
  440. sums[index] = micrometerFormat(instoreSum);
  441. }
  442. //金额总计
  443. if (item.property == "referenceOceanFreight") {
  444. sums[index] = micrometerFormat(totalSum);
  445. }
  446. //实际海运费
  447. if (item.property == "oceanFreight") {
  448. sums[index] = micrometerFormat(oceanFreightSum);
  449. }
  450. if (item.property == "orderQuantity") {
  451. sums[index] = orderQuantitySum
  452. ? orderQuantitySum.toFixed(2)
  453. : "0.00";
  454. }
  455. if (item.property == "actualQuantity") {
  456. sums[index] = actualQuantitySum
  457. ? actualQuantitySum.toFixed(2)
  458. : "0.00";
  459. }
  460. if (item.property == "amount") {
  461. sums[index] = micrometerFormat(amountSum);
  462. }
  463. if (item.property == "purchaseAmount") {
  464. sums[index] = micrometerFormat(purchaseAmountSum);
  465. }
  466. }
  467. });
  468. }
  469. return sums;
  470. },
  471. async saveColumn() {
  472. const inSave = await this.saveColumnData(
  473. this.getColumnName(4),
  474. this.option
  475. );
  476. if (inSave) {
  477. this.$message.success("保存成功");
  478. //关闭窗口
  479. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  480. }
  481. },
  482. async resetColumn() {
  483. this.option = option;
  484. const inSave = await this.delColumnData(this.getColumnName(4), option);
  485. if (inSave) {
  486. this.$message.success("重置成功");
  487. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  488. }
  489. }
  490. },
  491. watch: {
  492. option: function() {
  493. this.search.businesDate = defaultDate();
  494. }
  495. }
  496. };
  497. </script>
  498. <style scoped>
  499. ::v-deep .select-component {
  500. display: flex;
  501. }
  502. .page-crad ::v-deep .basic-container__card {
  503. height: 94.2vh;
  504. }
  505. ::v-deep .el-table__expanded-cell[class*="cell"] {
  506. padding: 0px;
  507. }
  508. .itemTable ::v-deep .el-table {
  509. width: 738px;
  510. }
  511. </style>