selectGlSalesModal.vue 11 KB

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