selectGlSalesModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <a-modal
  3. centered
  4. class="collection-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="90%">
  12. <a-spin :spinning="spinning" tip="Loading...">
  13. <div class="common-main">
  14. <!-- 搜索条件 -->
  15. <div ref="tableSearch" class="table-page-search-wrapper">
  16. <a-form layout="inline">
  17. <a-row :gutter="15">
  18. <a-col :md="4" :sm="24">
  19. <a-form-item label="销售单号">
  20. <a-input id="pushOrder-salesBillNo" v-model.trim="queryParam.salesBillNo" allowClear placeholder="请输入销售单号"/>
  21. </a-form-item>
  22. </a-col>
  23. <a-col :md="4" :sm="24">
  24. <a-form-item label="备货单号">
  25. <a-input id="pushOrder-dispatchBillNo" v-model.trim="queryParam.dispatchBillNo" allowClear placeholder="请输入备货单号"/>
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  30. <dealerSubareaScopeList ref="dealerSubareaScopeList" id="pushOrder-buyerName" @change="custChange" />
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="收货客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  35. <dealerSubareaScopeList ref="shbuyerName" id="pushOrder-shbuyerName" @change="shcustChange" />
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="4" :sm="24">
  39. <span class="table-page-search-submitButtons">
  40. <a-button type="primary" :disabled="disabled" @click="$refs.table.refresh(true)">查询</a-button>
  41. <a-button style="margin-left: 8px" :disabled="disabled" @click="resetSearchForm()">重置</a-button>
  42. </span>
  43. </a-col>
  44. </a-row>
  45. </a-form>
  46. </div>
  47. <!-- 表格数据 -->
  48. <s-table
  49. class="sTable"
  50. ref="table"
  51. size="small"
  52. :rowKey="(record) => record.id"
  53. :columns="columns"
  54. :data="loadData"
  55. :defaultLoadData="false"
  56. :scroll="{ y: 400 }"
  57. :pageSize="10"
  58. bordered>
  59. <!-- 销售单号 -->
  60. <template slot="salesBillNo" slot-scope="text, record">
  61. <span class="link-bule" v-if="$hasPermissions('B_salesDetail')" @click="handleDetail(record,0)">{{ record.salesBillNo }}</span>
  62. <span v-else>{{ record.salesBillNo }}</span>
  63. </template>
  64. <!-- 备货单号 -->
  65. <template slot="dispatchBillNo" slot-scope="text, record">
  66. <span class="link-bule" v-if="$hasPermissions('B_dispatchDetail')" @click="handleDetail(record,1)">{{ record.dispatchBillNo }}</span>
  67. <span v-else>{{ record.dispatchBillNo }}</span>
  68. </template>
  69. <!-- 操作 -->
  70. <template slot="action" slot-scope="text, record">
  71. <div v-if="record.financialStatus!='FINISH'&&record.billStatus!='STOCK_UP_REJECT'">
  72. <a-button
  73. size="small"
  74. type="link"
  75. class="button-warning"
  76. v-if="!record.checked"
  77. @click="handleChoose(record)"
  78. >选择</a-button>
  79. <span style="color:#55aa00;" v-else>已选</span>
  80. </div>
  81. <span style="color:#55aa00;" v-else>
  82. {{ record.checked?'已选':'--' }}
  83. </span>
  84. </template>
  85. </s-table>
  86. </div>
  87. <!-- 查看销售单或备货单详情 -->
  88. <commonModal
  89. :modalTit="detailType?'备货单详情':'销售单详情'"
  90. bodyPadding="10px"
  91. width="70%"
  92. :showFooter="false"
  93. :openModal="showDetailModal"
  94. @cancel="cancelDetail">
  95. <salesDetail v-if="detailType==0" ref="salesDetail" :bizSn="bizSn"></salesDetail>
  96. <dispatchDetail v-if="detailType==1" ref="dispatchDetail" :bizSn="bizSn"></dispatchDetail>
  97. </commonModal>
  98. </a-spin>
  99. </a-modal>
  100. </template>
  101. <script>
  102. import { commonMixin } from '@/utils/mixin'
  103. import { STable, VSelect } from '@/components'
  104. import { dispatchlList } from '@/api/dispatch'
  105. import commonModal from '@/views/common/commonModal.vue'
  106. import salesDetail from '@/views/salesManagement/salesQueryNew/detailAll.vue'
  107. import dispatchDetail from '@/views/salesManagement/pushOrderManagement/detail.vue'
  108. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  109. export default {
  110. name: 'SelectGlSalesModal',
  111. mixins: [commonMixin],
  112. components: { STable, VSelect, dealerSubareaScopeList, commonModal, salesDetail, dispatchDetail },
  113. props: {
  114. openModal: { // 弹框显示状态
  115. type: Boolean,
  116. default: false
  117. },
  118. modalTit: { // 弹框标题
  119. type: String,
  120. default: null
  121. },
  122. chooseData: {
  123. type: Array,
  124. default: function () {
  125. return []
  126. }
  127. },
  128. payerType:{
  129. type: String,
  130. default: ''
  131. },
  132. loading: {
  133. type: Boolean,
  134. default: false
  135. },
  136. dealerSn: {
  137. type: String,
  138. default: null
  139. }
  140. },
  141. data () {
  142. return {
  143. isShow: this.openModal, // 是否打开弹框
  144. disabled: false,
  145. spinning: false,
  146. showDetailModal: false,
  147. detailType: 2,
  148. bizSn: null,
  149. queryParam: {
  150. buyerSn: undefined, // 客户名称
  151. receiverSn: undefined, // 收货客户
  152. salesBillNo: '', // 销售单号
  153. dispatchBillNo: '' // 备货单号
  154. },
  155. orginData: [],
  156. // 加载数据方法 必须为 Promise 对象
  157. loadData: parameter => {
  158. this.disabled = true
  159. this.spinning = true
  160. return dispatchlList(Object.assign(parameter, this.queryParam, {authFlag:this.payerType=='DEALER'?1:0})).then(res => {
  161. let data
  162. if (res.status == 200) {
  163. data = res.data
  164. const no = (data.pageNo - 1) * data.pageSize
  165. for (var i = 0; i < data.list.length; i++) {
  166. data.list[i].no = no + i + 1
  167. const index = this.chooseData.findIndex(item => (data.list[i].dispatchBillSn == item.dispatchBillSn && data.list[i].salesBillSn == item.salesBillSn))
  168. data.list[i].checked = index >= 0
  169. }
  170. this.disabled = false
  171. }
  172. this.spinning = false
  173. this.orginData = data.list
  174. return data
  175. })
  176. },
  177. snList: []
  178. }
  179. },
  180. computed: {
  181. columns () {
  182. const arr = [
  183. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  184. { title: '创建时间', dataIndex: 'createDate', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  185. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '8%', align: 'center' },
  186. { title: '备货单号', scopedSlots: { customRender: 'dispatchBillNo' }, width: '10%', align: 'center' },
  187. { title: '客户名称', dataIndex: 'buyerName', width: '8%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  188. { title: '收货客户名称', dataIndex: 'receiverName', width: '8%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  189. { title: '发货编号', dataIndex: 'sendNo', width: '5%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  190. { title: '产品款数', dataIndex: 'totalCategory', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  191. { title: '产品数量', dataIndex: 'totalQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  192. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  193. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  194. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  195. ]
  196. if (this.$hasPermissions('B_glDispatch_salesPrice')) { // 售价权限
  197. arr.splice(10, 0, { title: '总售价', dataIndex: 'totalAmount', width: '5%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  198. }
  199. return arr
  200. }
  201. },
  202. methods: {
  203. custChange (val) {
  204. this.queryParam.buyerSn = val.key
  205. },
  206. shcustChange (val) {
  207. this.queryParam.receiverSn = val.key
  208. },
  209. handleDetail (row, type) {
  210. this.detailType = type
  211. this.bizSn = type == 0 ? row.salesBillSn : row.dispatchBillSn
  212. this.showDetailModal = true
  213. console.log(this.bizSn)
  214. },
  215. cancelDetail () {
  216. this.showDetailModal = false
  217. this.detailType = 2
  218. this.bizSn = null
  219. },
  220. // 删除
  221. handleDel (row) {
  222. const oi = this.orginData.findIndex(item => row.bizSn == item.dispatchBillSn)
  223. if (oi >= 0) {
  224. this.orginData[oi].checked = false
  225. }
  226. },
  227. // 选择
  228. handleChoose (row) {
  229. row.checked = true
  230. this.$emit('choose', {
  231. bizType: 'DISPATCH',
  232. bizSn: row.dispatchBillSn,
  233. bizNo: row.dispatchBillNo
  234. })
  235. },
  236. // 取消
  237. handleCommonCancel () {
  238. this.$emit('cancel')
  239. },
  240. // 重置
  241. resetSearchForm (flag) {
  242. this.queryParam = {
  243. buyerSn: undefined, // 客户名称
  244. receiverSn: undefined, // 收货客户
  245. salesBillNo: '', // 销售单号
  246. dispatchBillNo: '' // 备货单号
  247. }
  248. this.orginData = []
  249. this.$nextTick(() => {
  250. this.$refs.dealerSubareaScopeList.resetForm()
  251. this.$refs.shbuyerName.resetForm()
  252. })
  253. if (this.$refs.table && !flag) {
  254. this.$nextTick(() => {
  255. this.$refs.table.refresh(true)
  256. })
  257. }
  258. }
  259. },
  260. watch: {
  261. loading (newValue, oldValue) {
  262. this.spinning = newValue
  263. },
  264. // 父页面传过来的弹框状态
  265. openModal (newValue, oldValue) {
  266. this.isShow = newValue
  267. },
  268. // 重定义的弹框状态
  269. isShow (newValue, oldValue) {
  270. if (!newValue) {
  271. this.handleCommonCancel()
  272. } else {
  273. this.resetSearchForm(1)
  274. if (this.dealerSn) {
  275. // 回显客户
  276. this.queryParam.buyerSn = this.dealerSn
  277. this.$nextTick(() => {
  278. this.$refs.dealerSubareaScopeList.getDetail(this.dealerSn)
  279. this.$refs.table.refresh(true)
  280. })
  281. } else {
  282. this.$nextTick(() => {
  283. this.$refs.table.refresh(true)
  284. })
  285. }
  286. }
  287. }
  288. }
  289. }
  290. </script>
  291. <style lang="less">
  292. </style>