selectGlSalesModal.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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/salesQuery/detail.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. loading: {
  129. type: Boolean,
  130. default: false
  131. },
  132. dealerSn: {
  133. type: String,
  134. default: null
  135. }
  136. },
  137. data () {
  138. return {
  139. isShow: this.openModal, // 是否打开弹框
  140. disabled: false,
  141. spinning: false,
  142. showDetailModal: false,
  143. detailType: 2,
  144. bizSn: null,
  145. queryParam: {
  146. buyerSn: undefined, // 客户名称
  147. receiverSn: undefined, // 收货客户
  148. salesBillNo: '', // 销售单号
  149. dispatchBillNo: '' // 备货单号
  150. },
  151. orginData: [],
  152. // 加载数据方法 必须为 Promise 对象
  153. loadData: parameter => {
  154. this.disabled = true
  155. this.spinning = true
  156. return dispatchlList(Object.assign(parameter, this.queryParam)).then(res => {
  157. let data
  158. if (res.status == 200) {
  159. data = res.data
  160. const no = (data.pageNo - 1) * data.pageSize
  161. for (var i = 0; i < data.list.length; i++) {
  162. data.list[i].no = no + i + 1
  163. const index = this.chooseData.findIndex(item => (data.list[i].dispatchBillSn == item.dispatchBillSn && data.list[i].salesBillSn == item.salesBillSn))
  164. data.list[i].checked = index >= 0
  165. }
  166. this.disabled = false
  167. }
  168. this.spinning = false
  169. this.orginData = data.list
  170. return data
  171. })
  172. },
  173. snList: []
  174. }
  175. },
  176. computed: {
  177. columns () {
  178. const arr = [
  179. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  180. { title: '创建时间', dataIndex: 'createDate', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  181. { title: '销售单号', scopedSlots: { customRender: 'salesBillNo' }, width: '8%', align: 'center' },
  182. { title: '备货单号', scopedSlots: { customRender: 'dispatchBillNo' }, width: '10%', align: 'center' },
  183. { title: '客户名称', dataIndex: 'buyerName', width: '8%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  184. { title: '收货客户名称', dataIndex: 'receiverName', width: '8%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  185. { title: '发货编号', dataIndex: 'sendNo', width: '5%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  186. { title: '产品款数', dataIndex: 'totalCategory', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  187. { title: '产品数量', dataIndex: 'totalQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  188. { title: '业务状态', dataIndex: 'billStatusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  189. { title: '财务状态', dataIndex: 'financialStatusDictValue', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  191. ]
  192. if (this.$hasPermissions('B_glDispatch_salesPrice')) { // 售价权限
  193. arr.splice(10, 0, { title: '总售价', dataIndex: 'totalAmount', width: '5%', align: 'right', customRender: text => ((text || text == 0) ? this.toThousands(text) : '--') })
  194. }
  195. return arr
  196. }
  197. },
  198. methods: {
  199. custChange (val) {
  200. this.queryParam.buyerSn = val.key
  201. },
  202. shcustChange (val) {
  203. this.queryParam.receiverSn = val.key
  204. },
  205. handleDetail (row, type) {
  206. this.detailType = type
  207. this.bizSn = type == 0 ? row.salesBillSn : row.dispatchBillSn
  208. this.showDetailModal = true
  209. console.log(this.bizSn)
  210. },
  211. cancelDetail () {
  212. this.showDetailModal = false
  213. this.detailType = 2
  214. this.bizSn = null
  215. },
  216. // 删除
  217. handleDel (row) {
  218. const oi = this.orginData.findIndex(item => row.bizSn == item.dispatchBillSn)
  219. if (oi >= 0) {
  220. this.orginData[oi].checked = false
  221. }
  222. },
  223. // 选择
  224. handleChoose (row) {
  225. row.checked = true
  226. this.$emit('choose', {
  227. bizType: 'DISPATCH',
  228. bizSn: row.dispatchBillSn,
  229. bizNo: row.dispatchBillNo
  230. })
  231. },
  232. // 取消
  233. handleCommonCancel () {
  234. this.$emit('cancel')
  235. },
  236. // 重置
  237. resetSearchForm (flag) {
  238. this.queryParam = {
  239. buyerSn: undefined, // 客户名称
  240. receiverSn: undefined, // 收货客户
  241. salesBillNo: '', // 销售单号
  242. dispatchBillNo: '' // 备货单号
  243. }
  244. this.orginData = []
  245. this.$nextTick(() => {
  246. this.$refs.dealerSubareaScopeList.resetForm()
  247. this.$refs.shbuyerName.resetForm()
  248. })
  249. if (this.$refs.table && !flag) {
  250. this.$nextTick(() => {
  251. this.$refs.table.refresh(true)
  252. })
  253. }
  254. }
  255. },
  256. watch: {
  257. loading (newValue, oldValue) {
  258. this.spinning = newValue
  259. },
  260. // 父页面传过来的弹框状态
  261. openModal (newValue, oldValue) {
  262. this.isShow = newValue
  263. },
  264. // 重定义的弹框状态
  265. isShow (newValue, oldValue) {
  266. if (!newValue) {
  267. this.handleCommonCancel()
  268. } else {
  269. this.resetSearchForm(1)
  270. if (this.dealerSn) {
  271. // 回显客户
  272. this.queryParam.buyerSn = this.dealerSn
  273. this.$nextTick(() => {
  274. this.$refs.dealerSubareaScopeList.getDetail(this.dealerSn)
  275. this.$refs.table.refresh(true)
  276. })
  277. } else {
  278. this.$nextTick(() => {
  279. this.$refs.table.refresh(true)
  280. })
  281. }
  282. }
  283. }
  284. }
  285. }
  286. </script>
  287. <style lang="less">
  288. </style>