index.vue 19 KB

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