setPriceModal.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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>
  55. <a-form layout="inline" style="margin-bottom:10px;" @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>
  68. <!-- 表格数据 -->
  69. <s-table
  70. class="sTable"
  71. ref="table"
  72. size="small"
  73. :rowKey="(record) => record.id"
  74. :columns="columns"
  75. :data="loadData"
  76. :scroll="{ y: 400 }"
  77. :showPagination="false"
  78. bordered>
  79. </s-table>
  80. </div>
  81. </a-spin>
  82. </a-modal>
  83. </template>
  84. <script>
  85. import debounce from 'lodash/debounce'
  86. import { STable, VSelect } from '@/components'
  87. import { salesDetailByNo } from '@/api/sales'
  88. import { setReturnPrice } from '@/api/salesReturnDetail'
  89. export default {
  90. name: 'SetPriceModal',
  91. components: { STable, VSelect },
  92. props: {
  93. openModal: { // 弹框显示状态
  94. type: Boolean,
  95. default: false
  96. },
  97. modalTit: { // 弹框标题
  98. type: String,
  99. default: null
  100. },
  101. chooseData: {
  102. type: Array,
  103. default: function () {
  104. return []
  105. }
  106. }
  107. },
  108. data () {
  109. this.fetchUser = debounce(this.fetchUser, 800)
  110. return {
  111. isShow: this.openModal, // 是否打开弹框
  112. disabled: false,
  113. spinning: false,
  114. queryParam: {
  115. productName: '',
  116. productCode: ''
  117. },
  118. form: {
  119. grabFlag: 0, // 是否抓单
  120. discountFlag: 0, // 是否打折
  121. discount: '', // 折扣
  122. salesBillNo: '' // 销售单号
  123. },
  124. columns: [
  125. { title: '序号', dataIndex: 'no', width: '6%', align: 'center' },
  126. { title: '产品编码', dataIndex: 'productEntity.code', align: 'center', width: '13%', customRender: function (text) { return text || '--' } },
  127. { title: '产品名称', dataIndex: 'productEntity.name', width: '25%', align: 'left', customRender: function (text) { return text || '--' } },
  128. { title: '单位', dataIndex: 'productEntity.unit', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  129. { title: '申请退货数量', dataIndex: 'qty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  130. { title: '仓库实收数量', dataIndex: 'receiveQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  131. { title: '坏件数量', dataIndex: 'badQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  132. { title: '良品数量', dataIndex: 'goodQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  133. { title: '返库数量', dataIndex: 'backStockQty', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  134. { title: '实际退货单价', dataIndex: 'price', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  135. { title: '实际退货金额', dataIndex: 'totalAmount', align: 'center', width: '10%', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  136. { title: '退货单价说明', dataIndex: 'priceRemark', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  137. { title: '退货原因', dataIndex: 'returnReasonDictValue', width: '15%', align: 'center', customRender: function (text) { return text || '--' } }
  138. ],
  139. // 加载数据方法 必须为 Promise 对象
  140. loadData: parameter => {
  141. return new Promise((res, rej) => {
  142. const ret = this.chooseData.filter(item => {
  143. return item.productEntity.code.indexOf(this.queryParam.productCode) >= 0 &&
  144. item.productEntity.name.indexOf(this.queryParam.productName) >= 0
  145. })
  146. res({
  147. list: ret,
  148. count: ret.length
  149. })
  150. })
  151. },
  152. buyerName: ''
  153. }
  154. },
  155. methods: {
  156. fetchUser () {
  157. this.form.salesBillNo = this.form.salesBillNo.replace(/\s+/g, '')
  158. if (!this.form.salesBillNo) {
  159. this.form.salesBillNo = ''
  160. this.buyerName = ''
  161. return
  162. }
  163. this.spinning = true
  164. salesDetailByNo({ salesBillNo: this.form.salesBillNo }).then(res => {
  165. this.spinning = false
  166. this.buyerName = res.data ? res.data.buyerName : ''
  167. })
  168. },
  169. // 设置价格
  170. handleSave () {
  171. // 不抓单且打折
  172. if (this.form.grabFlag == 0 && this.form.discountFlag == 1) {
  173. if (!this.form.discount) {
  174. this.$message.info('请输入折扣')
  175. return
  176. }
  177. }
  178. // 抓单
  179. if (this.form.grabFlag == 1) {
  180. if (!this.form.salesBillNo) {
  181. this.$message.info('请输入销售单号')
  182. return
  183. }
  184. }
  185. const snList = []
  186. this.chooseData.map(item => {
  187. snList.push(item.salesReturnDetailSn)
  188. })
  189. const params = Object.assign(this.form, { salesReturnBillDetailSnList: snList })
  190. console.log(params)
  191. this.disabled = true
  192. this.spinning = true
  193. setReturnPrice(params).then(res => {
  194. if (res.status == 200) {
  195. this.$emit('setOk')
  196. this.$message.info(res.message)
  197. }
  198. this.disabled = false
  199. this.spinning = false
  200. })
  201. },
  202. grabChange (e) {
  203. if (e.target.value == 1) {
  204. this.form.salesBillNo = ''
  205. } else {
  206. this.form.discountFlag = 0
  207. this.form.discount = ''
  208. }
  209. },
  210. // 取消
  211. handleCommonCancel () {
  212. this.$emit('cancel')
  213. },
  214. // 查询
  215. searchProduct () {
  216. this.$refs.table.refresh(true)
  217. },
  218. // 重置
  219. resetSearchForm () {
  220. this.form = {
  221. grabFlag: 0, // 是否抓单
  222. discountFlag: 0, // 是否打折
  223. discount: '', // 折扣
  224. salesBillNo: '' // 销售单号
  225. }
  226. this.queryParam = {
  227. productName: '',
  228. productCode: ''
  229. }
  230. if (this.$refs.table) {
  231. this.$refs.table.refresh(true)
  232. }
  233. }
  234. },
  235. watch: {
  236. // 父页面传过来的弹框状态
  237. openModal (newValue, oldValue) {
  238. this.isShow = newValue
  239. },
  240. // 重定义的弹框状态
  241. isShow (newValue, oldValue) {
  242. if (!newValue) {
  243. this.handleCommonCancel()
  244. } else {
  245. this.resetSearchForm()
  246. }
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="less">
  252. .setPrice-detail-modal{
  253. .form-row{
  254. > div{
  255. display: flex;
  256. align-items:center;
  257. padding: 10px 0;
  258. input[type='text']{
  259. width:250px;
  260. }
  261. .mleft{
  262. margin-left:10px;
  263. }
  264. }
  265. }
  266. }
  267. </style>