index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <template>
  2. <div>
  3. <basic-container v-show="show" class="page-crad">
  4. <avue-crud
  5. :key="key"
  6. ref="crud"
  7. :option="option"
  8. :data="dataList"
  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. :table-loading="loading"
  17. @saveColumn="saveColumn"
  18. @resetColumn="resetColumn"
  19. :cell-style="cellStyle"
  20. @search-criteria-switch="searchCriteriaSwitch"
  21. @expand-change="expandChange">
  22. <template slot="menuLeft">
  23. <div style="display:flex;padding-top: 10px">
  24. <el-badge
  25. v-for="item of badgeList"
  26. :hidden="item.dictionaryStatus == '全部'?true:false"
  27. :value="item.count"
  28. :max="99"
  29. class="item"
  30. type="danger">
  31. <el-button
  32. style="border-radius: 0"
  33. :type="search.status == item.status?'success':''"
  34. size="mini"
  35. @click="query(item.status)">
  36. {{ item.dictionaryStatus }}
  37. </el-button>
  38. </el-badge>
  39. <el-button type="primary" size="mini" @click.stop="newAdd()">新建销售单</el-button>
  40. </div>
  41. </template>
  42. <template slot="expand" slot-scope="{row}">
  43. <avue-crud
  44. ref="expandCrud"
  45. :option="optionList"
  46. :table-loading="row.loading"
  47. :data="row.orderItemsList"></avue-crud>
  48. </template>
  49. <template slot="corpIdSearch">
  50. <crop-select v-model="search.corpId" corpType="KH"></crop-select>
  51. </template>
  52. <template slot-scope="{ row, index }" slot="corpId">
  53. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 1)">{{ row.corpsName }}</span>
  54. </template>
  55. <template slot-scope="{ row, index }" slot="sysNo">
  56. <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row, 1)">{{ row.sysNo }}</span>
  57. </template>
  58. <template slot="businesDateSearch">
  59. <el-date-picker
  60. v-model="search.businesDate"
  61. type="daterange"
  62. start-placeholder="开始日期"
  63. end-placeholder="结束日期"
  64. format="yyyy-MM-dd"
  65. value-format="yyyy-MM-dd HH:mm:ss"
  66. :default-time="['00:00:00', '23:59:59']"
  67. :picker-options="pickerOptions">
  68. </el-date-picker>
  69. </template>
  70. <template slot-scope="{ row, index }" slot="menu">
  71. <!-- <el-tooltip class="item" effect="dark" content="新建销售订单" placement="top">
  72. <i class="tradingIcon icon-add" />
  73. </el-tooltip> -->
  74. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  75. <i class="tradingIcon icon-del" v-if="row.confirmStatus == 0" @click.stop="rowDel(row, index)"/>
  76. </el-tooltip>
  77. <!-- <el-tooltip class="item" effect="dark" content="编辑" placement="top">-->
  78. <!-- <i class="tradingIcon icon-edit" />-->
  79. <!-- </el-tooltip>-->
  80. <!-- <el-tooltip class="item" effect="dark" content="收款" placement="top">-->
  81. <!-- <i class="tradingIcon icon-proceeds" />-->
  82. <!-- </el-tooltip>-->
  83. <el-tooltip class="item" effect="dark" content="发货" placement="top">
  84. <i class="tradingIcon icon-deliver" v-if="row.status == 3" @click.stop="deliverGoods(row, index)"/>
  85. </el-tooltip>
  86. <!-- <el-tooltip class="item" effect="dark" content="对账" placement="top">-->
  87. <!-- <i class="tradingIcon icon-reconciliation" />-->
  88. <!-- </el-tooltip>-->
  89. <!-- <el-button type="text" size="small" @click.stop="editOpen(row, 2)">
  90. 查看
  91. </el-button>
  92. <el-button type="text" size="small" @click.stop="rowDel(row, index)">
  93. 删除
  94. </el-button> -->
  95. </template>
  96. </avue-crud>
  97. </basic-container>
  98. <details-page v-if="!show" @goBack="goBack()" :detailData="detailData"/>
  99. <el-dialog
  100. title="发货"
  101. :visible.sync="dialogVisible"
  102. append-to-body
  103. close-on-click-modal
  104. close-on-press-escape
  105. width="40%">
  106. <div class="elForm">
  107. <el-form :model="form" label-position="right">
  108. <el-col :span="24">
  109. <el-form-item label="收货人姓名:" label-width="100px">
  110. <span>{{ form.corpAttn }}</span>
  111. </el-form-item>
  112. <el-form-item label="收货人电话:" label-width="100px">
  113. <span>{{ form.corpTel }}</span>
  114. </el-form-item>
  115. <el-form-item label="收货人地址:" label-width="100px">
  116. <span>{{ form.arrivalAddress }}</span>
  117. </el-form-item>
  118. </el-col>
  119. <el-col :span="24">
  120. <el-form-item label="快递公司:" label-width="100px">
  121. <!-- <el-input v-model="form.courierCorporation" placeholder="请输入快递公司" size="small" style="width: 100%;"></el-input>-->
  122. <el-select v-model="form.courierCorporation" placeholder="请选择快递公司" clearable filterable
  123. size="small" style="width: 90%;">
  124. <el-option
  125. v-for="item in courierServices"
  126. :key="item.dictKey"
  127. :label="item.dictValue"
  128. :value="item.dictKey">
  129. </el-option>
  130. </el-select>
  131. </el-form-item>
  132. </el-col>
  133. <el-col :span="24">
  134. <el-form-item label="快递单号:" label-width="100px">
  135. <el-input
  136. v-model="form.courierNumber"
  137. placeholder="请输入快递单号"
  138. size="small"
  139. style="width: 90%;"></el-input>
  140. </el-form-item>
  141. </el-col>
  142. </el-form>
  143. </div>
  144. <span slot="footer" class="dialog-footer">
  145. <el-button size="small" @click="dialogVisible = false">取 消</el-button>
  146. <el-button size="small" type="primary" @click="confirmShipment">确认发货</el-button>
  147. </span>
  148. </el-dialog>
  149. </div>
  150. </template>
  151. <script>
  152. import detailsPage from "./detailsPage";
  153. import {option} from "./js/optionList";
  154. import {optionList} from "./js/optionList";
  155. import {
  156. getListTwo,
  157. getCorpsAll,
  158. gainUser,
  159. getCorpType,
  160. orderRemove,
  161. statusStatisticsApi,
  162. delivery, getDetails, getStoragelist
  163. } from "@/api/basicData/salesOrder";
  164. export default {
  165. name: "index",
  166. data() {
  167. return {
  168. src: '',
  169. form: {},
  170. optionList: {
  171. header: false,
  172. align: "center",
  173. addBtn: false,
  174. refreshBtn: false,
  175. editBtn: false,
  176. delBtn: false,
  177. columnBtn: false,
  178. border: true,
  179. menuWidth: 120,
  180. stripe: true,
  181. index: true,
  182. menu: false,
  183. expandRowKeys: [],
  184. rowKey: 'id',
  185. indexSlot: true,
  186. showSummary: true,
  187. summaryText: "合计",
  188. sumColumnList: [
  189. {
  190. name: "amount",
  191. type: "sum"
  192. },
  193. {
  194. name: "storageAmount",
  195. type: "sum"
  196. },
  197. {
  198. name: "storageInQuantity",
  199. type: "sum"
  200. },
  201. {
  202. name: "actualQuantity",
  203. type: "sum"
  204. }
  205. ],
  206. column: [
  207. {
  208. label: "产品",
  209. prop: "cname",
  210. width: '250px',
  211. // overHidden: true
  212. },
  213. {
  214. label: "仓库",
  215. prop: "storageId",
  216. overHidden: true,
  217. type: "select",
  218. props: {
  219. label: "cname",
  220. value: "id"
  221. },
  222. dicData: []
  223. },
  224. {
  225. label: "数量",
  226. prop: "storageInQuantity",
  227. overHidden: true
  228. },
  229. {
  230. label: "单位",
  231. prop: "unit",
  232. type: "select",
  233. props: {
  234. label: "dictValue",
  235. value: "dictValue"
  236. },
  237. dicData: [],
  238. cell: true,
  239. overHidden: true
  240. },
  241. {
  242. label: "单价",
  243. prop: "price",
  244. overHidden: true
  245. },
  246. {
  247. label: "金额",
  248. prop: "amount",
  249. overHidden: true
  250. },
  251. {
  252. label: "送货数量",
  253. prop: "actualQuantity",
  254. type: 'number',
  255. controls: false,
  256. cell: true,
  257. overHidden: true
  258. },
  259. {
  260. label: "备注",
  261. prop: "remarks",
  262. cell: true,
  263. overHidden: true
  264. },
  265. {
  266. label: "进价",
  267. prop: "purchasePrice",
  268. overHidden: true
  269. }
  270. ]
  271. },
  272. dialogVisible: false,
  273. badgeList: [],
  274. show: true,
  275. loading: false,
  276. search: {
  277. status: ''
  278. },
  279. detailData: {},
  280. dataList: [],
  281. selectionList: [],
  282. key: 0,
  283. page: {
  284. pageSize: 20,
  285. currentPage: 1,
  286. total: 0,
  287. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  288. },
  289. option: {},
  290. pickerOptions: {
  291. shortcuts: [
  292. {
  293. text: '当天',
  294. onClick(picker) {
  295. const date = new Date();
  296. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0);
  297. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
  298. picker.$emit('pick', [start, end]);
  299. }
  300. },
  301. {
  302. text: '昨天',
  303. onClick(picker) {
  304. const date = new Date();
  305. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1, 0, 0, 0);
  306. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1, 23, 59, 59);
  307. picker.$emit('pick', [start, end]);
  308. }
  309. }, {
  310. text: '当月',
  311. onClick(picker) {
  312. const date = new Date();
  313. const start = new Date(date.getFullYear(), date.getMonth(), 1, 0, 0, 0);
  314. const end = new Date(date.getFullYear(), date.getMonth() + 1, 0, 23, 59, 59);
  315. picker.$emit('pick', [start, end]);
  316. }
  317. }, {
  318. text: '当季',
  319. onClick(picker) {
  320. const date = new Date();
  321. const start = new Date(date.getFullYear(), parseInt(date.getMonth() / 3) * 3, 1, 0, 0, 0);
  322. const end = new Date(date.getFullYear(), parseInt(date.getMonth() / 3) * 3 + 3, 0, 23, 59, 59);
  323. picker.$emit('pick', [start, end]);
  324. }
  325. }, {
  326. text: '当年',
  327. onClick(picker) {
  328. const date = new Date();
  329. const start = new Date(date.getFullYear(), date.getMonth(), 1, 0, 0, 0);
  330. const end = new Date(date.getFullYear() + 1, 0, 0, 23, 59, 59);
  331. picker.$emit('pick', [start, end]);
  332. }
  333. }, {
  334. text: '最近一周',
  335. onClick(picker) {
  336. const date = new Date();
  337. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7, 0, 0, 0);
  338. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
  339. picker.$emit('pick', [start, end]);
  340. }
  341. }, {
  342. text: '最近二周',
  343. onClick(picker) {
  344. const date = new Date();
  345. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7 * 2, 0, 0, 0);
  346. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
  347. picker.$emit('pick', [start, end]);
  348. }
  349. }, {
  350. text: '最近三周',
  351. onClick(picker) {
  352. const date = new Date();
  353. const start = new Date(date.getFullYear(), date.getMonth(), date.getDate() - 7 * 3, 0, 0, 0);
  354. const end = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
  355. picker.$emit('pick', [start, end]);
  356. }
  357. }]
  358. },
  359. courierServices: []
  360. };
  361. },
  362. components: {
  363. detailsPage
  364. },
  365. async created() {
  366. this.option = await this.getColumnData(this.getColumnName(211), option);
  367. this.getAllWorkDicts()
  368. this.getWorkDicts("order_status_pjjl").then(res => {
  369. this.findObject(this.option.column, "status").dicData = res.data.data;
  370. this.findObject(this.option.column, "actualPaymentStatus").dicData = res.data.data;
  371. this.key++
  372. });
  373. this.getWorkDicts("courier_services").then(res => {
  374. this.courierServices = res.data.data
  375. });
  376. },
  377. activated() {
  378. this.$refs.crud.refreshTable();
  379. if (!this.$store.getters.pjxsStatus && !this.show) {
  380. this.show = true;
  381. }
  382. if (this.$route.query.orderId) {
  383. setTimeout(() => {
  384. this.editOpen({id: this.$route.query.orderId}, 1);
  385. }, 100);
  386. }
  387. if (this.$route.query.check) {
  388. this.show = true
  389. this.detailData = {
  390. id: this.$route.query.check.billId,
  391. check: this.$route.query.check,
  392. auditId: this.$route.query.check.id,
  393. };
  394. this.show = false;
  395. this.$store.commit("IN_PJXS_STATUS");
  396. }
  397. },
  398. methods: {
  399. confirmShipment() {
  400. if (!this.form.courierNumber) {
  401. this.$alert('是否继续发货', '未填写快递单号', {
  402. confirmButtonText: '确定',
  403. callback: action => {
  404. if (action === "confirm") {
  405. const loading = this.$loading({
  406. lock: true,
  407. text: '加载中',
  408. spinner: 'el-icon-loading',
  409. background: 'rgba(255,255,255,0.7)'
  410. });
  411. delivery({
  412. id: this.form.id,
  413. courierNumber: this.form.courierNumber,
  414. courierCorporation: this.form.courierCorporation
  415. }).then(res => {
  416. loading.close();
  417. this.$message.success("发货成功")
  418. this.dialogVisible = false
  419. this.onLoad(this.page)
  420. }).catch(() => {
  421. loading.close();
  422. })
  423. }
  424. }
  425. });
  426. } else {
  427. const loading = this.$loading({
  428. lock: true,
  429. text: '加载中',
  430. spinner: 'el-icon-loading',
  431. background: 'rgba(255,255,255,0.7)'
  432. });
  433. delivery({
  434. id: this.form.id,
  435. courierNumber: this.form.courierNumber,
  436. courierCorporation: this.form.courierCorporation
  437. }).then(res => {
  438. this.$message.success("发货成功")
  439. this.dialogVisible = false
  440. loading.close();
  441. this.onLoad(this.page)
  442. }).catch(() => {
  443. loading.close();
  444. })
  445. }
  446. },
  447. query(status) {
  448. this.search.status = status
  449. this.page.currentPage = 1;
  450. this.onLoad(this.page)
  451. },
  452. getAllWorkDicts() {
  453. gainUser().then(res => {
  454. this.findObject(this.option.column, "createUser").dicData = res.data.data;
  455. })
  456. getCorpType({corpType: 'KH'}).then(res => {
  457. this.findObject(this.option.column, "corpType").dicData = res.data.data;
  458. });
  459. this.$refs.crud.init();
  460. },
  461. expandChange(row, expendList) {
  462. this.getWorkDicts("unit").then(res => {
  463. this.findObject(this.optionList.column, "unit").dicData = res.data.data;
  464. });
  465. getStoragelist().then(res => {
  466. this.storageoptions = res.data;
  467. this.findObject(this.optionList.column, "storageId").dicData = res.data;
  468. })
  469. if (row) {
  470. row.loading = true
  471. getDetails({id: row.id}).then(res => {
  472. row.orderItemsList = res.data.data.orderItemsList
  473. row.loading = false
  474. })
  475. }
  476. },
  477. searchCriteriaSwitch(type) {
  478. this.$refs.crud.getTableHeight();
  479. },
  480. cellStyle() {
  481. return "padding:0;height:40px;";
  482. },
  483. //点击搜索按钮触发
  484. searchChange(params, done) {
  485. this.page.currentPage = 1;
  486. this.onLoad(this.page, params);
  487. done();
  488. },
  489. refreshChange() {
  490. this.onLoad(this.page, this.search);
  491. },
  492. newAdd() {
  493. this.show = false;
  494. this.$store.commit("IN_PJXS_STATUS");
  495. },
  496. onLoad(page, params = {}) {
  497. if (this.$refs.expandCrud) {
  498. this.dataList.forEach(item => {
  499. this.$refs.crud.toggleRowExpansion(item, false);
  500. });
  501. }
  502. statusStatisticsApi({type: '1'}).then(res => {
  503. this.badgeList = [];
  504. this.badgeList.push({
  505. count: 0,
  506. dictionaryStatus: "全部",
  507. status: ''
  508. });
  509. for (let item of res.data.data) {
  510. this.badgeList.push(item)
  511. }
  512. })
  513. let data = this.deepClone(Object.assign(params, this.search));
  514. data.billType = 'XS';
  515. data.tradeType = 'YPJ';
  516. if (data.businesDate) {
  517. data.orderStartDate = data.businesDate[0];
  518. data.orderEndDate = data.businesDate[1];
  519. }
  520. delete data.businesDate
  521. this.loading = true;
  522. getListTwo(
  523. page.currentPage,
  524. page.pageSize,
  525. data
  526. ).then(res => {
  527. this.dataList = res.data.data.records ? res.data.data.records : [];
  528. this.page.total = res.data.data.total;
  529. }).finally(() => {
  530. this.loading = false;
  531. });
  532. },
  533. editOpen(row, status) {
  534. this.detailData = {
  535. id: row.id,
  536. status: status,
  537. billType: row.billType
  538. };
  539. this.show = false;
  540. this.$store.commit("IN_PJXS_STATUS");
  541. },
  542. currentChange(val) {
  543. this.page.currentPage = val;
  544. },
  545. sizeChange(val) {
  546. this.page.currentPage = 1;
  547. this.page.pageSize = val;
  548. },
  549. rowDel(row, index, done) {
  550. this.$confirm("确定删除数据?", {
  551. confirmButtonText: "确定",
  552. cancelButtonText: "取消",
  553. type: "warning"
  554. }).then(() => {
  555. orderRemove(row.id).then(res => {
  556. if (res.data.code == 200) {
  557. this.$message({
  558. type: "success",
  559. message: "删除成功!"
  560. });
  561. this.onLoad(this.page, this.search);
  562. }
  563. });
  564. });
  565. },
  566. deliverGoods(row, index) {
  567. this.form = row
  568. this.dialogVisible = true
  569. },
  570. async saveColumn() {
  571. const inSave = await this.saveColumnData(
  572. this.getColumnName(211),
  573. this.option
  574. );
  575. if (inSave) {
  576. this.$nextTick(() => {
  577. this.$refs.crud.doLayout();
  578. });
  579. this.$message.success("保存成功");
  580. //关闭窗口
  581. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  582. }
  583. },
  584. async resetColumn() {
  585. this.option = option;
  586. const inSave = await this.delColumnData(this.getColumnName(211), option);
  587. if (inSave) {
  588. this.$nextTick(() => {
  589. this.$refs.crud.doLayout();
  590. });
  591. this.getAllWorkDicts()
  592. this.$message.success("重置成功");
  593. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  594. }
  595. },
  596. //返回列表
  597. goBack() {
  598. if (this.$route.query.orderId || this.$route.query.check) {
  599. this.$router.$avueRouter.closeTag(this.$route.fullPath);
  600. this.$router.push({
  601. path: "/salesOrder/index"
  602. });
  603. }
  604. this.detailData = this.$options.data().detailData;
  605. this.show = true;
  606. this.onLoad(this.page, this.search);
  607. this.$store.commit("OUT_PJXS_STATUS");
  608. },
  609. }
  610. }
  611. </script>
  612. <style lang="scss" scoped>
  613. .page-crad ::v-deep .basic-container__card {
  614. height: 94.2vh;
  615. }
  616. ::v-deep .el-badge__content.is-fixed {
  617. z-index: 10;
  618. right: 25px
  619. }
  620. .item {
  621. margin-right: -5px;
  622. //margin-bottom: 10px;
  623. }
  624. .stat-td {
  625. text-align: center;
  626. position: relative;
  627. }
  628. .stat-img {
  629. width: 95%;
  630. height: 100px;
  631. }
  632. .stat-tip {
  633. position: absolute;
  634. left: 15px;
  635. top: 5px;
  636. .money {
  637. color: #fff;
  638. font-size: 28px;
  639. text-align: left;
  640. font-weight: 600;
  641. }
  642. .title {
  643. color: #fff;
  644. font-size: 14px;
  645. text-align: left;
  646. margin-top: 5px;
  647. margin-bottom: 0px;
  648. }
  649. }
  650. ::v-deep .el-form-item__content {
  651. //margin-left: 90px;
  652. }
  653. ::v-deep .avue-crud__right {
  654. padding-top: 5px;
  655. }
  656. ::v-deep .elForm {
  657. .el-form-item {
  658. margin-bottom: 0;
  659. }
  660. }
  661. ::v-deep .el-dialog__body {
  662. padding: 0;
  663. }
  664. ::v-deep .el-form-item__label {
  665. //text-align: right;
  666. //vertical-align: middle;
  667. //float: left;
  668. //font-size: 14px;
  669. //color: #606266;
  670. //line-height: 40px;
  671. padding: 0 4px 0 0;
  672. //box-sizing: border-box;
  673. }
  674. </style>