outStockModal.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <a-modal
  3. centered
  4. class="outStock-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. v-model="isShow"
  8. @cancel="isShow=false"
  9. :width="900">
  10. <div slot="title">
  11. <strong>采购缺货产品明细</strong>
  12. <span style="color: #ed1c24;;margin-left:10px;font-size: 12px;" v-if="purchaseTargetType&&(purchaseTargetType=='DEALER_UP'||purchaseTargetType=='DEALER_SUPPLIER')">注意:仅可添加本供应商有权限的产品</span>
  13. <span style="color: #ed1c24;;margin-left:10px;font-size: 12px;" v-else-if="purchaseTargetType&&purchaseTargetType=='SUPPLIER_SYS'">注意:仅可添加本供应商有经销权且总部已上线的产品</span>
  14. </div>
  15. <a-spin :spinning="spinning" tip="Loading...">
  16. <div class="outStock-con">
  17. <div>
  18. <div ref="tableSearch" class="table-page-search-wrapper">
  19. <a-form layout="inline" @keyup.enter.native="searchForm">
  20. <a-row :gutter="15">
  21. <a-col :md="8" :sm="24">
  22. <a-form-item label="采购单号">
  23. <a-input id="productInfoList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" placeholder="请输入采购单号" allowClear />
  24. </a-form-item>
  25. </a-col>
  26. <a-col :md="8" :sm="24">
  27. <a-form-item label="产品编码">
  28. <a-input id="productInfoList-code" v-model.trim="queryParam.dealerProduct.code" allowClear placeholder="请输入产品编码"/>
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="8" :sm="24">
  32. <a-form-item label="产品名称">
  33. <a-input id="productInfoList-name" v-model.trim="queryParam.dealerProduct.name" allowClear placeholder="请输入产品名称"/>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="8" :sm="24">
  37. <a-form-item label="产品分类">
  38. <ProductType id="productInfoList-productType" placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :md="8" :sm="24">
  42. <a-form-item label="产品品牌">
  43. <ProductBrand id="productInfoList-productBrandSn" placeholder="请选择产品品牌" v-model="queryParam.dealerProduct.productBrandSn"></ProductBrand>
  44. </a-select>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :md="8" :sm="24" style="margin-bottom: 10px;">
  48. <a-button type="primary" @click="searchForm" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  49. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  50. </a-col>
  51. </a-row>
  52. </a-form>
  53. </div>
  54. <p style="font-weight: bold;">当前已选:{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys?rowSelectionInfo.selectedRowKeys.length:0 }}个</p>
  55. <!-- 列表 -->
  56. <s-table
  57. class="sTable"
  58. ref="table"
  59. size="small"
  60. :rowKey="(record) => record.id"
  61. :row-selection="{ columnWidth: 40 ,getCheckboxProps:record=>({props:{disabled:(purchaseTargetType&&purchaseTargetType=='SUPPLIER_SYS'&&record.onlineFalg == 0)||record.productPowerFlag==0}})}"
  62. @rowSelection="rowSelectionFun"
  63. :data="loadData"
  64. :columns="columns"
  65. :scroll="{ y: 450 }"
  66. :defaultLoadData="false"
  67. bordered>
  68. <!-- 产品编码 -->
  69. <template slot="productCode" slot-scope="text, record">
  70. {{ record.productCode }}
  71. <a-tag v-if="record.onlineFalg == 0">下架</a-tag>
  72. <a-tag color="red" v-if="record.productPowerFlag== 0">无权限</a-tag>
  73. </template>
  74. </s-table>
  75. </div>
  76. <!-- 按钮 -->
  77. <div class="btn-con">
  78. <a-button
  79. id="outStock-cancel"
  80. size="large"
  81. class="button-cancel"
  82. @click="isShow=false"
  83. style="padding: 0 60px;margin-right: 15px;">取消</a-button>
  84. <a-button
  85. type="primary"
  86. id="outStock-save"
  87. size="large"
  88. class="button-primary"
  89. @click="handleSave"
  90. style="padding: 0 36px;">批量添加</a-button>
  91. </div>
  92. </div>
  93. </div></a-spin>
  94. </a-modal>
  95. </template>
  96. <script>
  97. import { commonMixin } from '@/utils/mixin'
  98. import { STable } from '@/components'
  99. import { outOfStockDetailList } from '@/api/oos'
  100. import { importOosDetail } from '@/api/purchaseDetail'
  101. import ProductType from '../../common/productType.js'
  102. import ProductBrand from '../../common/productBrand.js'
  103. export default {
  104. name: 'OutStockModal',
  105. components: { STable, ProductType, ProductBrand },
  106. mixins: [commonMixin],
  107. props: {
  108. openModal: { // 弹框显示状态
  109. type: Boolean,
  110. default: false
  111. },
  112. paramsSn: {
  113. type: String,
  114. default: ''
  115. },
  116. chooseData: {
  117. type: Array,
  118. default: () => {
  119. return []
  120. }
  121. },
  122. purchaseTargetType: {
  123. type: String,
  124. default: null
  125. }
  126. },
  127. data () {
  128. const _this = this
  129. return {
  130. isShow: _this.openModal, // 是否打开弹框
  131. formItemLayout: {
  132. labelCol: { span: 4 },
  133. wrapperCol: { span: 20 }
  134. },
  135. disabled: false, // 查询、重置按钮是否可操作
  136. columns: [
  137. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  138. { title: '采购单号', dataIndex: 'purchaseBillNo', width: '18%', align: 'center', customRender: function (text) { return text || '--' } },
  139. { title: '产品编码', dataIndex: 'productCode', width: '18%', align: 'center', scopedSlots: { customRender: 'productCode' } },
  140. { title: '产品名称', dataIndex: 'productName', width: '30%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  141. { title: '缺货数量', dataIndex: 'qty', width: '15%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  142. { title: '缺货金额', dataIndex: 'totalAmount', width: '15%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } },
  143. { title: '单位', dataIndex: 'unit', width: '10%', align: 'center', customRender: function (text) { return text || '--' } }
  144. ],
  145. // 加载数据方法 必须为 Promise 对象
  146. loadData: parameter => {
  147. this.disabled = true
  148. this.spinning = true
  149. this.queryParam.purchaseBillSnList = this.chooseData
  150. return outOfStockDetailList(Object.assign(parameter, this.queryParam)).then(res => {
  151. let data
  152. if (res.status == 200) {
  153. data = res.data
  154. const no = (data.pageNo - 1) * data.pageSize
  155. for (var i = 0; i < data.list.length; i++) {
  156. data.list[i].no = no + i + 1
  157. }
  158. this.disabled = false
  159. }
  160. this.spinning = false
  161. return data
  162. })
  163. },
  164. spinning: false,
  165. rowSelectionInfo: null,
  166. productType: [],
  167. queryParam: { // 查询条件
  168. purchaseBillSnList: undefined,
  169. purchaseBillNo: '',
  170. dealerProduct: {
  171. code: '', // 产品编码
  172. name: '', // 产品名称
  173. productBrandSn: undefined, // 产品品牌
  174. productTypeSn1: '', // 产品一级分类
  175. productTypeSn2: '', // 产品二级分类
  176. productTypeSn3: '' // 产品三级分类
  177. },
  178. newPurchaseBillSn: _this.paramsSn
  179. }
  180. }
  181. },
  182. methods: {
  183. // 产品分类 change
  184. changeProductType (val, opt) {
  185. this.queryParam.dealerProduct.productTypeSn1 = val[0] ? val[0] : ''
  186. this.queryParam.dealerProduct.productTypeSn2 = val[1] ? val[1] : ''
  187. this.queryParam.dealerProduct.productTypeSn3 = val[2] ? val[2] : ''
  188. },
  189. // 表格选中项
  190. rowSelectionFun (obj) {
  191. this.rowSelectionInfo = obj || null
  192. },
  193. // 保存
  194. handleSave () {
  195. const _this = this
  196. if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  197. this.$message.warning('请在列表勾选后再进行操作!')
  198. return
  199. }
  200. const arr = []
  201. _this.rowSelectionInfo.selectedRows.forEach(item => {
  202. const obj = {
  203. productSn: item.productSn,
  204. productCode: item.productCode,
  205. qty: item.qty
  206. }
  207. arr.push(obj)
  208. })
  209. importOosDetail({ purchaseBillSn: _this.paramsSn, arr }).then(res => {
  210. if (res.status == 200) {
  211. _this.$emit('ok')
  212. }
  213. })
  214. },
  215. searchForm () {
  216. this.$refs.table.refresh(true)
  217. },
  218. resetSearchForm () {
  219. this.queryParam.purchaseBillNo = ''
  220. const info = {
  221. productBrandSn: undefined,
  222. code: '', // 产品编码
  223. name: '', // 产品名称
  224. productTypeSn1: '', // 产品一级分类
  225. productTypeSn2: '', // 产品二级分类
  226. productTypeSn3: '' // 产品三级分类
  227. }
  228. this.productType = []
  229. Object.assign(this.queryParam.dealerProduct, info)
  230. this.$refs.table.refresh(true)
  231. }
  232. },
  233. watch: {
  234. // 父页面传过来的弹框状态
  235. openModal (newValue, oldValue) {
  236. this.isShow = newValue
  237. },
  238. // 重定义的弹框状态
  239. isShow (newValue, oldValue) {
  240. if (!newValue) {
  241. this.$emit('close')
  242. this.$refs.table.clearSelected() // 清空表格选中项
  243. }
  244. }
  245. }
  246. }
  247. </script>
  248. <style lang="less" scoped>
  249. .outStock-modal{
  250. .outStock-con{
  251. .btn-con{
  252. text-align: center;
  253. margin: 30px 0 20px;
  254. .button-cancel{
  255. font-size: 12px;
  256. }
  257. }
  258. }
  259. }
  260. </style>