index.vue 16 KB

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