setPriceModal.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <a-modal
  3. centered
  4. class="setPrice-detail-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. v-model="isShow"
  8. :title="modalTit"
  9. :bodyStyle="{padding: modalTit?'25px 32px 20px':'50px 32px 15px'}"
  10. @cancel="isShow=false"
  11. width="80%">
  12. <a-spin :spinning="spinning" tip="Loading...">
  13. <div class="common-main">
  14. <div class="form-row">
  15. <div>
  16. 退货单价:
  17. <a-radio-group v-model="form.grabFlag" @change="grabChange">
  18. <a-radio :value="0">
  19. 不抓单
  20. </a-radio>
  21. <a-radio :value="1">
  22. 抓单
  23. </a-radio>
  24. </a-radio-group>
  25. </div>
  26. <div v-if="form.grabFlag==0">
  27. 是否打折:
  28. <a-radio-group v-model="form.discountFlag">
  29. <a-radio :value="0">
  30. 不打折
  31. </a-radio>
  32. <a-radio :value="1">
  33. 打折
  34. </a-radio>
  35. </a-radio-group>
  36. <div v-if="form.discountFlag==1">
  37. <a-input-number placeholder="请输入折扣" v-model="form.discount" :min="0" :max="10" :precision="2" />
  38. <span class="mleft">示例:7折表示使用当前售价×0.7作为退货单价(保留两位小数)</span>
  39. <a-button type="primary" :disabled="disabled" @click="handleSave" class="button-error">设置完成</a-button>
  40. </div>
  41. <div v-else>
  42. <a-button type="primary" :disabled="disabled" @click="handleSave" class="button-error">设置完成</a-button>
  43. </div>
  44. </div>
  45. <div v-else>
  46. 销售单号:
  47. <a-input placeholder="请输入销售单号" v-model.trim="form.salesBillNo" :maxlength="50" @change="fetchUser"/>
  48. <span class="mleft">{{ buyerName }}</span>
  49. <a-button type="primary" :disabled="disabled" @click="handleSave" class="button-error">设置完成</a-button>
  50. </div>
  51. </div>
  52. <a-divider>请给以下产品设置新的退货单价</a-divider>
  53. <!-- 搜索条件 -->
  54. <div style="overflow: hidden;">
  55. <a-form layout="inline" style="margin-bottom:10px;float:left;" @keyup.enter.native="searchProduct">
  56. <a-form-item label="产品编码">
  57. <a-input id="setPrice-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  58. </a-form-item>
  59. <a-form-item label="产品名称">
  60. <a-input id="setPrice-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
  61. </a-form-item>
  62. <a-form-item>
  63. <a-button type="primary" class="button-info" @click="searchProduct" :disabled="disabled" id="setPrice-refresh">查询</a-button>
  64. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="setPrice-reset">重置</a-button>
  65. </a-form-item>
  66. </a-form>
  67. <div style="float:right;color:#999;margin-top:10px;">说明:红色行表示收货时新增的产品;黄色表示客服确认时新增的产品</div>
  68. </div>
  69. <!-- 表格数据 -->
  70. <s-table
  71. class="sTable"
  72. ref="table"
  73. size="small"
  74. :rowKey="(record) => record.id"
  75. :rowClassName="(record, index) => record.addFlag == '1' ? (record.addType == 'WAREHOUSE_RECEIVE'?'redBg-row':'orgBg-row'):''"
  76. :columns="columns"
  77. :data="loadData"
  78. :scroll="{ y: 400 }"
  79. :showPagination="false"
  80. bordered>
  81. </s-table>
  82. </div>
  83. </a-spin>
  84. </a-modal>
  85. </template>
  86. <script>
  87. import { commonMixin } from '@/utils/mixin'
  88. import debounce from 'lodash/debounce'
  89. import { STable, VSelect } from '@/components'
  90. import { salesDetailByNo } from '@/api/sales'
  91. import { setReturnPrice } from '@/api/salesReturnDetail'
  92. export default {
  93. name: 'SetPriceModal',
  94. mixins: [commonMixin],
  95. components: { STable, VSelect },
  96. props: {
  97. openModal: { // 弹框显示状态
  98. type: Boolean,
  99. default: false
  100. },
  101. modalTit: { // 弹框标题
  102. type: String,
  103. default: null
  104. },
  105. chooseData: {
  106. type: Array,
  107. default: function () {
  108. return []
  109. }
  110. }
  111. },
  112. data () {
  113. this.fetchUser = debounce(this.fetchUser, 800)
  114. return {
  115. isShow: this.openModal, // 是否打开弹框
  116. disabled: false,
  117. spinning: false,
  118. queryParam: {
  119. productName: '',
  120. productCode: ''
  121. },
  122. form: {
  123. grabFlag: 0, // 是否抓单
  124. discountFlag: 0, // 是否打折
  125. discount: '', // 折扣
  126. salesBillNo: '' // 销售单号
  127. },
  128. columns: [
  129. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  130. { title: '产品编码', dataIndex: 'productEntity.code', align: 'center', width: '13%', customRender: function (text) { return text || '--' } },
  131. { title: '产品名称', dataIndex: 'productEntity.name', width: '25%', align: 'left', customRender: function (text) { return text || '--' } },
  132. { title: '单位', dataIndex: 'productEntity.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  133. { title: '申请退货数量', dataIndex: 'qty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  134. { title: '仓库实收数量', dataIndex: 'receiveQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  135. { title: '坏件数量', dataIndex: 'badQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  136. { title: '良品数量', dataIndex: 'goodQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  137. { title: '返库数量', dataIndex: 'backStockQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  138. { title: '退货单价', dataIndex: 'price', align: 'right', width: '10%', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') },
  139. { title: '退货单价说明', dataIndex: 'priceRemark', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '退货原因', dataIndex: 'returnReason', width: '15%', align: 'center', customRender: function (text) { return text || '--' } }
  141. ],
  142. // 加载数据方法 必须为 Promise 对象
  143. loadData: parameter => {
  144. return new Promise((res, rej) => {
  145. const ret = this.chooseData.filter(item => {
  146. return item.productEntity.code.indexOf(this.queryParam.productCode) >= 0 &&
  147. item.productEntity.name.indexOf(this.queryParam.productName) >= 0
  148. })
  149. res({
  150. list: ret,
  151. count: ret.length
  152. })
  153. })
  154. },
  155. buyerName: ''
  156. }
  157. },
  158. methods: {
  159. fetchUser () {
  160. this.form.salesBillNo = this.form.salesBillNo.replace(/\s+/g, '')
  161. if (!this.form.salesBillNo) {
  162. this.form.salesBillNo = ''
  163. this.buyerName = ''
  164. return
  165. }
  166. this.spinning = true
  167. salesDetailByNo({ salesBillNo: this.form.salesBillNo }).then(res => {
  168. this.spinning = false
  169. this.buyerName = res.data ? res.data.buyerName : ''
  170. })
  171. },
  172. // 设置价格
  173. handleSave () {
  174. // 不抓单且打折
  175. if (this.form.grabFlag == 0 && this.form.discountFlag == 1) {
  176. if (!this.form.discount) {
  177. this.$message.info('请输入折扣')
  178. return
  179. }
  180. }
  181. // 抓单
  182. if (this.form.grabFlag == 1) {
  183. if (!this.form.salesBillNo) {
  184. this.$message.info('请输入销售单号')
  185. return
  186. }
  187. this.form.discountFlag = undefined
  188. this.form.discount = undefined
  189. }
  190. const snList = []
  191. this.chooseData.map(item => {
  192. snList.push(item.salesReturnDetailSn)
  193. })
  194. const params = Object.assign(this.form, { salesReturnBillDetailSnList: snList })
  195. console.log(params)
  196. this.disabled = true
  197. this.spinning = true
  198. setReturnPrice(params).then(res => {
  199. if (res.status == 200) {
  200. this.$emit('setOk')
  201. this.$message.info(res.message)
  202. }
  203. this.disabled = false
  204. this.spinning = false
  205. })
  206. },
  207. grabChange (e) {
  208. this.buyerName = ''
  209. if (e.target.value == 1) {
  210. this.form.salesBillNo = ''
  211. } else {
  212. this.form.discountFlag = 0
  213. this.form.discount = ''
  214. }
  215. },
  216. // 取消
  217. handleCommonCancel () {
  218. this.$emit('cancel')
  219. },
  220. // 查询
  221. searchProduct () {
  222. this.$refs.table.refresh(true)
  223. },
  224. // 重置
  225. resetSearchForm () {
  226. this.form = {
  227. grabFlag: 0, // 是否抓单
  228. discountFlag: 0, // 是否打折
  229. discount: '', // 折扣
  230. salesBillNo: '' // 销售单号
  231. }
  232. this.queryParam = {
  233. productName: '',
  234. productCode: ''
  235. }
  236. this.buyerName = ''
  237. if (this.$refs.table) {
  238. this.$refs.table.refresh(true)
  239. }
  240. }
  241. },
  242. watch: {
  243. // 父页面传过来的弹框状态
  244. openModal (newValue, oldValue) {
  245. this.isShow = newValue
  246. },
  247. // 重定义的弹框状态
  248. isShow (newValue, oldValue) {
  249. if (!newValue) {
  250. this.handleCommonCancel()
  251. } else {
  252. this.resetSearchForm()
  253. }
  254. }
  255. }
  256. }
  257. </script>
  258. <style lang="less">
  259. .setPrice-detail-modal{
  260. .form-row{
  261. > div{
  262. display: flex;
  263. align-items:center;
  264. padding: 10px 0;
  265. input[type='text']{
  266. width:250px;
  267. }
  268. .mleft{
  269. margin-left:10px;
  270. }
  271. }
  272. }
  273. .redBg-row{
  274. background-color: #f5beb4;
  275. }
  276. .orgBg-row{
  277. background-color: #fffca2;
  278. }
  279. }
  280. </style>