outStockModal.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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="orderType">注意:仅可添加本供应商有经销权且总部已上线的{{ orderType=='TIRE'?'轮胎':'非轮胎' }}产品</span>
  13. <span style="color: #ed1c24;;margin-left:10px;font-size: 12px;" v-else>注意:仅可添加本供应商有权限的产品</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: { // sn
  113. type: String,
  114. default: ''
  115. },
  116. chooseData: { // 已选数据
  117. type: Array,
  118. default: () => {
  119. return []
  120. }
  121. },
  122. orderType: {// 是否是轮胎产品
  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, // 已选sn列表
  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. // 格式化数据
  201. const arr = []
  202. _this.rowSelectionInfo.selectedRows.forEach(item => {
  203. const obj = {
  204. productSn: item.productSn,
  205. productCode: item.productCode,
  206. qty: item.qty
  207. }
  208. arr.push(obj)
  209. })
  210. importOosDetail({ purchaseBillSn: _this.paramsSn, arr }).then(res => {
  211. if (res.status == 200) {
  212. _this.$emit('ok')
  213. }
  214. })
  215. },
  216. // 查询
  217. searchForm () {
  218. this.$refs.table.refresh(true)
  219. },
  220. // 重置
  221. resetSearchForm () {
  222. this.queryParam.purchaseBillNo = '' // 采购单号
  223. const info = {
  224. productBrandSn: undefined, // 采购sn
  225. code: '', // 产品编码
  226. name: '', // 产品名称
  227. productTypeSn1: '', // 产品一级分类
  228. productTypeSn2: '', // 产品二级分类
  229. productTypeSn3: '' // 产品三级分类
  230. }
  231. this.productType = [] // 产品分类
  232. Object.assign(this.queryParam.dealerProduct, info)
  233. this.$refs.table.refresh(true)
  234. }
  235. },
  236. watch: {
  237. // 父页面传过来的弹框状态
  238. openModal (newValue, oldValue) {
  239. this.isShow = newValue
  240. },
  241. // 重定义的弹框状态
  242. isShow (newValue, oldValue) {
  243. if (!newValue) {
  244. this.$emit('close')
  245. this.$refs.table.clearSelected() // 清空表格选中项
  246. }
  247. }
  248. }
  249. }
  250. </script>
  251. <style lang="less" scoped>
  252. .outStock-modal{
  253. .outStock-con{
  254. .btn-con{
  255. text-align: center;
  256. margin: 30px 0 20px;
  257. .button-cancel{
  258. font-size: 12px;
  259. }
  260. }
  261. }
  262. }
  263. </style>