edit.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div class="salesNewEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" @back="handleBack" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="salesEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. <span style="margin: 0 15px;color: #666;font-weight: bold;">单号:{{ detailData&&detailData.salesBillNo }}</span>
  9. <span v-if="detailData&&detailData.salesBillNoSource">(原:{{ detailData&&detailData.salesBillNoSource || '--' }})</span>
  10. <span style="margin-left:15px;color:#00aaff;cursor:pointer;" @click="showDetail=!showDetail">
  11. <a-icon title="查看信息" type="eye"/> 查看信息
  12. </span>
  13. </template>
  14. </a-page-header>
  15. <!-- 单据详情 -->
  16. <a-card size="small" :bordered="false" class="salesEdit-cont" v-show="showDetail">
  17. <div style="padding: 10px;">
  18. <a-descriptions size="small" :column="3">
  19. <a-descriptions-item label="客户名称">{{ detailData&&detailData.buyerName || '--' }}</a-descriptions-item>
  20. <a-descriptions-item label="收货地址" :span="2">{{ shippingAddress||'--' }}</a-descriptions-item>
  21. <a-descriptions-item label="收货人">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeName || '--' }}</a-descriptions-item>
  22. <a-descriptions-item label="收货电话">{{ detailData&&detailData.salesBillExtEntity&&detailData.salesBillExtEntity.consigneeTel || '--' }}</a-descriptions-item>
  23. <a-descriptions-item label="收款方式">{{ detailData&&detailData.settleStyleSnDictValue || '--' }}</a-descriptions-item>
  24. <a-descriptions-item label="审核时间">{{ detailData&&detailData.auditDate || '--' }}</a-descriptions-item>
  25. <a-descriptions-item label="业务状态">{{ detailData&&detailData.billStatusDictValue || '--' }}</a-descriptions-item>
  26. <a-descriptions-item label="财务状态">{{ detailData&&detailData.financialStatusDictValue || '--' }}</a-descriptions-item>
  27. <a-descriptions-item label="备注" :span="3">{{ detailData&&detailData.remarks || '--' }}</a-descriptions-item>
  28. </a-descriptions>
  29. </div>
  30. </a-card>
  31. <!-- 正常产品 -->
  32. <a-card size="small" :bordered="false" class="salesEdit-cont" v-if="salesBillSn">
  33. <div style="padding: 10px;">
  34. <productNormalList
  35. ref="productNormalList"
  36. @openCpModal="openProductModal"
  37. :detailData="detailData"
  38. :warehouseSn="warehouseSn"
  39. :salesBillSn="salesBillSn"></productNormalList>
  40. </div>
  41. </a-card>
  42. <!-- 活动产品 -->
  43. <a-card
  44. size="small"
  45. :bordered="false"
  46. class="salesEdit-cont"
  47. v-for="item in activeList"
  48. :key="item.promoRuleSn"
  49. >
  50. <div slot="title" style="display: inline-block;width:100%;">
  51. <strong style="margin-right:10px;font-size:14px;">{{item.promotion.title}}</strong> ({{item.promotionRule.description}})
  52. <span style="margin-left:20px;color:#00aaff;cursor: pointer;" @click="(event) => {showDesc(event, item)}">
  53. <a-icon title="查看活动详情" type="eye"/> 活动详情
  54. </span>
  55. <span style="margin:0 20px;color:#ff0800;cursor: pointer;" @click="(event) => {disabledActive(event, item)}">
  56. <a-icon title="禁用规则" type="disconnect"/> 禁用规则
  57. </span>
  58. </div>
  59. <div slot="extra" @click="tooglePanel(item)" style="cursor: pointer;">{{ item.isActive ? '收起' : '展开' }} <a-icon type="caret-right" :rotate="item.isActive ? 90 : 0"/> </div>
  60. <div v-show="item.isActive" style="padding: 10px;">
  61. <productList
  62. :ref="'productList-'+item.promoRuleSn"
  63. :id="item.promoRuleSn"
  64. @openCpModal="openProductModal"
  65. @insterOk="insterActiveOk"
  66. :promo="item"
  67. :detailData="detailData"
  68. :warehouseSn="warehouseSn"
  69. :salesBillSn="salesBillSn"></productList>
  70. </div>
  71. </a-card>
  72. </a-spin>
  73. <div class="affix-cont">
  74. <div class="footer-price">
  75. <div></div>
  76. <div>
  77. <div class="totalPrice">合计:¥<span>121.60</span></div>
  78. <div>
  79. 产品总款数:<strong>12</strong>;
  80. 总数量:<strong>111</strong>;
  81. 总售价:<strong>17898.88</strong>;
  82. <span style="margin-right:10px;">优惠金额:<strong>121.60</strong></span>
  83. <a-popover title="优惠明细">
  84. <a-button shape="round" size="small">优惠明细</a-button>
  85. <div slot="content">
  86. <div class="yhdetail" style="min-width:300px;">
  87. <div class="yhdetail-h" style="font-weight: bold;font-size:14px;">520以爱之名保护你</div>
  88. <div style="padding-left:10px;">
  89. <div>卖产品送产品:¥<strong>220</strong></div>
  90. <div class="yhdetail-d" style="color:#999;">满10送2</div>
  91. </div>
  92. </div>
  93. <div class="yhdetail">
  94. <div class="yhdetail-h" style="font-weight: bold;font-size:14px;">滤清器夏季大派送</div>
  95. <div style="padding-left:10px;">
  96. <div>卖产品送产品:¥<strong>220</strong></div>
  97. <div class="yhdetail-d" style="color:#999;">满10送2</div>
  98. </div>
  99. </div>
  100. <div class="yhdetail">
  101. <div class="yhdetail-h" style="font-weight: bold;font-size:14px;">520以爱之名保护你</div>
  102. <div style="padding-left:10px;">
  103. <div>卖产品送产品:¥<strong>220</strong></div>
  104. <div class="yhdetail-d" style="color:#999;">满10送2</div>
  105. </div>
  106. </div>
  107. </div>
  108. </a-popover>
  109. </div>
  110. </div>
  111. </div>
  112. <div>
  113. <a-button
  114. size="large"
  115. style="padding: 0 60px;"
  116. :disabled="spinning"
  117. type="primary"
  118. class="button-primary"
  119. @click="handleSubmit()"
  120. id="productInfoList-handleSubmit">提交</a-button>
  121. </div>
  122. </div>
  123. <!-- 添加产品 -->
  124. <chooseProduct
  125. ref="chooseProduct"
  126. :openModal="showCpModal"
  127. @close="closeProductModal"
  128. @addProduct="insterProduct"></chooseProduct>
  129. <!-- 价格更新弹窗 -->
  130. <setPriceModal :show="priceUpdateModal" :totalRealAmount="updataData.totalRealAmount" :totalAmount="updataData.totalAmount" @ok="updatePrice" @cancel="priceUpdateModal=false"></setPriceModal>
  131. </div>
  132. </template>
  133. <script>
  134. import { commonMixin } from '@/utils/mixin'
  135. import productList from './comps/productList.vue'
  136. import productNormalList from './comps/productNormalList.vue'
  137. import chooseProduct from './comps/chooseProduct.vue'
  138. import setPriceModal from './setPriceModal.vue'
  139. import { salesDisablePromo } from '@/api/salesDetailNew'
  140. import { salesDetailBySn, salesWriteSubmit, submitCheck, updateBatch, salesPromoQueryList, salesQueryUnPartPromo } from '@/api/salesNew'
  141. export default {
  142. name: 'SalesNewEdit',
  143. mixins: [commonMixin],
  144. components:{
  145. setPriceModal,
  146. productList,
  147. chooseProduct,
  148. productNormalList
  149. },
  150. data () {
  151. return {
  152. spinning: false,
  153. activeList:[], // 活动列表
  154. activeDesKey: {},
  155. salesBillSn: null, // 销售单sn
  156. detailData: { discountAmount: 0, id: null, salesBillSn: '' }, // 订单基础数据
  157. warehouseSn: undefined,
  158. updataData: {
  159. totalRealAmount: '',
  160. totalAmount: ''
  161. },
  162. priceUpdateModal: false, // 价格更新弹窗
  163. showDetail: false,
  164. showCpModal: false,
  165. cpCurRefId: '',
  166. disabledActiveOption: null
  167. }
  168. },
  169. computed: {
  170. shippingAddress () {
  171. const shippingAddrProvinceName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrProvinceName ? this.detailData.salesBillExtEntity.shippingAddrProvinceName : ''
  172. const shippingAddrCityName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCityName ? this.detailData.salesBillExtEntity.shippingAddrCityName : ''
  173. const shippingAddrCountyName = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddrCountyName ? this.detailData.salesBillExtEntity.shippingAddrCountyName : ''
  174. const shippingAddr = this.detailData && this.detailData.salesBillExtEntity && this.detailData.salesBillExtEntity.shippingAddr ? this.detailData.salesBillExtEntity.shippingAddr : ''
  175. if (!shippingAddrProvinceName && !shippingAddrCityName && !shippingAddrCountyName && !shippingAddr) {
  176. return '--'
  177. } else {
  178. return shippingAddrProvinceName + shippingAddrCityName + shippingAddrCountyName + shippingAddr
  179. }
  180. }
  181. },
  182. methods: {
  183. // 返回
  184. handleBack () {
  185. this.$router.push({ name: 'salesQueryNewList', query: { closeLastOldTab: true } })
  186. },
  187. tooglePanel(item){
  188. item.isActive=!item.isActive
  189. this.activeList.splice()
  190. },
  191. // 销售单详情
  192. getOrderDetail (flag) {
  193. salesDetailBySn({ salesBillSn: this.$route.params.sn }).then(res => {
  194. if (res.status == 200) {
  195. this.detailData = res.data
  196. }
  197. this.getActiveList()
  198. })
  199. },
  200. // 获取销售单参与的活动列表
  201. async getActiveList(){
  202. const hasNewActive = await salesQueryUnPartPromo({ salesBillSn: this.$route.params.sn }).then(res => res.data)
  203. console.log(hasNewActive)
  204. // 有新活动
  205. if(hasNewActive.length){
  206. this.showNewActiveModal(hasNewActive)
  207. }
  208. this.activeList = await salesPromoQueryList({ salesBillSn: this.$route.params.sn }).then(res => res.data || [])
  209. this.activeList.map(item => {
  210. item.isActive = true
  211. this.activeDesKey['search-'+item.promoRuleSn] = false
  212. })
  213. },
  214. // 新活动确认弹框
  215. showNewActiveModal(data){
  216. let arr = []
  217. data.map(item => {
  218. arr.push(item.title)
  219. })
  220. this.$confirm({
  221. title: '新活动提醒',
  222. centered: true,
  223. class:'confirm-center',
  224. content: <div>
  225. <div style="padding:10px 0;text-align:center;">
  226. 系统发布新的促销活动:
  227. </div>
  228. <div style="text-align:center;color:#00aaff;">{arr.join(',')}</div>
  229. <div style="padding:10px 0;text-align:center;">
  230. 是否将现有产品识别到新的活动中吗?
  231. </div>
  232. </div>,
  233. onOk() {
  234. },
  235. onCancel() {},
  236. });
  237. },
  238. // 添加产品,包括正常和活动的产品
  239. closeProductModal(){
  240. this.cpCurRefId = ''
  241. this.showCpModal = false
  242. },
  243. // 打开选择产品弹框
  244. openProductModal(type, refId){
  245. console.log(type, refId)
  246. const promo = this.activeList.find(item => item.promoRuleSn == refId)
  247. this.$refs.chooseProduct.pageInit(this.detailData, promo, type)
  248. this.cpCurRefId = 'productList-' + refId
  249. this.showCpModal = true
  250. },
  251. // 添加活动产品成功的回调
  252. insterActiveOk(){
  253. // 刷新正常产品列表
  254. this.$refs.productNormalList.resetSearchForm()
  255. },
  256. // 新增产品
  257. insterProduct(row, promotionFlag, type){
  258. // 正常产品
  259. if(type == 0){
  260. this.$refs.productNormalList.insterProduct(row, promotionFlag)
  261. }else{
  262. // 活动产品
  263. this.$refs[this.cpCurRefId][0].insterProduct(row, promotionFlag, type)
  264. }
  265. },
  266. // 选择价格类型 并更新
  267. updatePrice (type) {
  268. const _this = this
  269. if (type == 0) {
  270. const ajax_data = {
  271. salesBillSn: _this.salesBillSn,
  272. productPriceChangeFlag: type
  273. }
  274. _this.submitResult(ajax_data)
  275. } else {
  276. updateBatch(_this.updataData.detailList).then(res => {
  277. if (res.status == 200) {
  278. const ajax_data = {
  279. salesBillSn: _this.salesBillSn,
  280. productPriceChangeFlag: type
  281. }
  282. _this.submitResult(ajax_data)
  283. }
  284. })
  285. }
  286. },
  287. // 提交销售单
  288. handleSubmit () {
  289. // 先不提交,先判断是否有价格更新 (下级创建时判断)
  290. if (this.detailData && this.detailData.salesBillSource && this.detailData.salesBillSource == 'PURCHASE') {
  291. submitCheck({ salesBillSn: this.salesBillSn }).then(res => {
  292. if (res.status == 200) {
  293. if (res.data.detailList.length > 0) {
  294. this.updataData = res.data
  295. const _this = this
  296. this.$nextTick(() => {
  297. _this.priceUpdateModal = true
  298. })
  299. } else {
  300. const ajax_data = { salesBillSn: this.salesBillSn }
  301. this.submitResult(ajax_data)
  302. }
  303. }
  304. })
  305. } else {
  306. const ajax_data = { salesBillSn: this.salesBillSn }
  307. this.submitResult(ajax_data)
  308. }
  309. },
  310. // 提交
  311. submitResult (data) {
  312. this.spinning = true
  313. salesWriteSubmit(data).then(res => {
  314. if (res.status == 200) {
  315. this.handleBack()
  316. this.$message.success(res.message)
  317. this.spinning = false
  318. } else {
  319. this.spinning = false
  320. }
  321. })
  322. },
  323. // 展开收缩活动详情
  324. showDesc(e,item){
  325. e.stopPropagation()
  326. const row = this.$refs['productList-'+item.promoRuleSn][0]
  327. row&&row.showDesc(item.promotionRule)
  328. },
  329. // 禁用活动
  330. disabledActive(e,item){
  331. const _this = this
  332. if(item.disabled){
  333. this.$message.info("规则已经禁用!")
  334. return
  335. }
  336. this.$confirm({
  337. title: '确定禁用规则?',
  338. centered: true,
  339. class:'confirm-center',
  340. content: <div>
  341. <div style="padding:10px 0;text-align:center;">禁用规则后,将无法享受该活动规则优惠</div>
  342. <div style="padding:0 0 10px 0;text-align:center;">
  343. <aRadioGroup onChange={_this.changeDaOpt}>
  344. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="DELETE">
  345. 删除规则中相关产品
  346. </aRadio>
  347. <aRadio style="display:block;height: '30px';lineHeight: '30px';padding:5px 0;" value="REMOVE">
  348. 移出规则中相关产品
  349. </aRadio>
  350. </aRadioGroup>
  351. </div>
  352. </div>,
  353. onOk() {
  354. if(_this.disabledActiveOption){
  355. salesDisablePromo({
  356. salesBillSn: _this.salesBillSn,
  357. salesPromoSn: item.salesPromoSn,
  358. promoRuleSn: item.promoRuleSn,
  359. salesDisableType: _this.disabledActiveOption
  360. }).then(res => {
  361. if(res.status == 200){
  362. _this.$refs['productList-'+item.promoRuleSn][0].disableActive()
  363. _this.disabledActiveOption = null
  364. item.disabled = true
  365. }
  366. })
  367. }else{
  368. _this.$message.info("请选择如何禁用规则!")
  369. return true
  370. }
  371. },
  372. onCancel() {
  373. _this.disabledActiveOption = null
  374. },
  375. });
  376. },
  377. changeDaOpt(e){
  378. console.log(e)
  379. this.disabledActiveOption = e.target.value
  380. },
  381. pageInit () {
  382. this.salesBillSn = this.$route.params.sn
  383. this.warehouseSn = this.$route.params.sn ? this.$route.params.wSn : ''
  384. this.getOrderDetail(true)
  385. }
  386. },
  387. mounted () {
  388. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  389. this.pageInit()
  390. }
  391. },
  392. activated () {
  393. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  394. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  395. this.pageInit()
  396. }
  397. },
  398. beforeRouteEnter (to, from, next) {
  399. next(vm => {})
  400. }
  401. }
  402. </script>
  403. <style lang="less">
  404. .salesNewEdit-wrap{
  405. position: relative;
  406. height: 100%;
  407. padding-bottom: 75px;
  408. box-sizing: border-box;
  409. >.ant-spin-nested-loading{
  410. overflow-y: auto;
  411. height: 100%;
  412. }
  413. .salesEdit-cont{
  414. margin: 10px 0;
  415. }
  416. .redStyle{
  417. font-weight: bold;
  418. color: red;
  419. }
  420. .ellipsisCon{
  421. display: flex;
  422. justify-content: space-between;
  423. align-items: center;
  424. .ellipsisText{
  425. width: 100%;
  426. overflow: hidden;
  427. text-overflow: ellipsis;
  428. display: box;
  429. display: -webkit-box;
  430. -webkit-line-clamp: 1;
  431. -webkit-box-orient: vertical;
  432. }
  433. }
  434. .ant-card-small > .ant-card-body {
  435. padding: 0!important;
  436. }
  437. .affix-cont{
  438. padding: 10px 15px;
  439. text-align: right;
  440. display: flex;
  441. justify-content: space-between;
  442. align-items: center;
  443. .footer-price{
  444. flex-grow:1;
  445. display: flex;
  446. justify-content: flex-end;
  447. align-items: center;
  448. > div{
  449. padding: 0 15px;
  450. }
  451. .totalPrice{
  452. span{
  453. font-weight: bold;
  454. color: red;
  455. font-size: 20px;
  456. }
  457. }
  458. }
  459. }
  460. }
  461. </style>