chooseShelfProduct.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <a-modal
  3. centered
  4. class="chooseShelf-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. :title="mtitle"
  8. v-model="isShow"
  9. @cancel="isShow = false"
  10. width="80%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-tabs>
  13. <a-tab-pane key="1" tab="待补货产品" force-render>
  14. <!-- 搜索条件 -->
  15. <div class="table-page-search-wrapper">
  16. <a-form-model
  17. ref="ruleForm"
  18. class="form-model-con"
  19. layout="inline"
  20. :model="queryParam"
  21. @keyup.enter.native="$refs.table.refresh(true)" >
  22. <a-row :gutter="5">
  23. <a-col :md="4" :sm="24">
  24. <a-form-model-item label="产品编码">
  25. <a-input id="chooseShelf-code" ref="searchProductCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :md="4" :sm="24">
  29. <a-form-model-item label="产品名称">
  30. <a-input id="chooseShelf-name" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  31. </a-form-model-item>
  32. </a-col>
  33. <a-col :md="4" :sm="24">
  34. <a-form-model-item label="产品分类">
  35. <ProductType id="chooseShelf-productType" :isDealer="true" @change="changeProductType" v-model="productType"></ProductType>
  36. </a-form-model-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-model-item label="库存情况">
  40. <a-checkbox-group :options="options" @change="onStockChange" />
  41. </a-form-model-item>
  42. </a-col>
  43. <a-col :md="6" :sm="12" style="margin-bottom: 10px;">
  44. <a-button type="primary" @click="$refs.table.refresh(true)" id="chooseShelf-refresh">查询</a-button>
  45. <a-button style="margin-left: 5px" @click="resetSearchForm" id="chooseShelf-reset">重置</a-button>
  46. </a-col>
  47. </a-row>
  48. </a-form-model>
  49. </div>
  50. <div class="chooseShelf-modal-table">
  51. <div class="table-operator">
  52. <div>
  53. <a-button type="primary" class="button-error">批量添加</a-button>
  54. <span v-if="selectTotal">已选{{ selectTotal }}项</span>
  55. </div>
  56. <div>
  57. <a-icon type="info-circle" />
  58. 此界面仅显示货架上需要补货的产品
  59. </div>
  60. </div>
  61. <!-- 列表 -->
  62. <s-table
  63. class="sTable"
  64. ref="table"
  65. size="small"
  66. :rowKey="(record) => record.id"
  67. :row-selection="{columnWidth: 40}"
  68. @rowSelection="rowSelectionFun"
  69. :columns="columns"
  70. :data="loadData"
  71. :scroll="{ y: 450 }"
  72. :defaultLoadData="false"
  73. :showPagination="false"
  74. bordered>
  75. </s-table>
  76. </div>
  77. </a-tab-pane>
  78. <a-tab-pane key="2" tab="全部货架产品" force-render>
  79. <!-- 搜索条件 -->
  80. <div class="table-page-search-wrapper">
  81. <a-form-model
  82. ref="ruleForm1"
  83. class="form-model-con"
  84. layout="inline"
  85. :model="queryParam1"
  86. @keyup.enter.native="$refs.table1.refresh(true)" >
  87. <a-row :gutter="5">
  88. <a-col :md="4" :sm="24">
  89. <a-form-model-item label="产品编码">
  90. <a-input id="chooseShelf-code1" v-model.trim="queryParam1.productCode" allowClear placeholder="请输入产品编码"/>
  91. </a-form-model-item>
  92. </a-col>
  93. <a-col :md="4" :sm="24">
  94. <a-form-model-item label="产品名称">
  95. <a-input id="chooseShelf-name1" v-model.trim="queryParam1.productName" allowClear placeholder="请输入产品名称"/>
  96. </a-form-model-item>
  97. </a-col>
  98. <a-col :md="4" :sm="24">
  99. <a-form-model-item label="产品分类">
  100. <ProductType id="chooseShelf-productType1" :isDealer="true" @change="changeProductType1" v-model="productType1"></ProductType>
  101. </a-form-model-item>
  102. </a-col>
  103. <a-col :md="6" :sm="12" style="margin-bottom: 10px;">
  104. <a-button type="primary" @click="$refs.table1.refresh(true)" id="chooseShelf-refresh">查询</a-button>
  105. <a-button style="margin-left: 5px" @click="resetSearchForm1" id="chooseShelf-reset">重置</a-button>
  106. </a-col>
  107. </a-row>
  108. </a-form-model>
  109. </div>
  110. <div class="chooseShelf-modal-table">
  111. <!-- 列表 -->
  112. <s-table
  113. class="sTable"
  114. ref="table1"
  115. size="small"
  116. :rowKey="(record) => record.id"
  117. :columns="columns1"
  118. :data="loadData1"
  119. :scroll="{ y: 450 }"
  120. :defaultLoadData="false"
  121. :showPagination="false"
  122. bordered>
  123. </s-table>
  124. </div>
  125. </a-tab-pane>
  126. </a-tabs>
  127. </a-spin>
  128. </a-modal>
  129. </template>
  130. <script>
  131. import { commonMixin } from '@/utils/mixin'
  132. import { STable } from '@/components'
  133. import ProductType from '../../common/productType.js'
  134. import { stockOutDetailList } from '@/api/stockOut'
  135. export default {
  136. name: 'OutinDetailModal',
  137. components: { STable, ProductType },
  138. mixins: [commonMixin],
  139. props: {
  140. openModal: {
  141. // 弹框显示状态
  142. type: Boolean,
  143. default: false
  144. },
  145. baseData: {
  146. type: Object,
  147. default: function () {
  148. return null
  149. }
  150. }
  151. },
  152. data () {
  153. return {
  154. spinning: false,
  155. advanced: false,
  156. isShow: this.openModal, // 是否打开弹框
  157. options: [
  158. { label: '库存充足', value: '1' },
  159. { label: '部分缺货', value: '2' },
  160. { label: '全部缺货', value: '3' }
  161. ],
  162. productType: [],
  163. queryParam: {
  164. productCode: '', // 产品编码
  165. productName: '', // 产品名称
  166. productTypeSn1: '', // 产品一级分类
  167. productTypeSn2: '', // 产品二级分类
  168. productTypeSn3: '' // 产品三级分类
  169. },
  170. // 加载数据方法 必须为 Promise 对象
  171. loadData: parameter => {
  172. this.spinning = true
  173. return stockOutDetailList(Object.assign(parameter, this.queryParam)).then(res => {
  174. let data
  175. if (res.status == 200) {
  176. data = res.data
  177. const no = 0
  178. for (var i = 0; i < data.length; i++) {
  179. data[i].no = no + i + 1
  180. data[i].totalCost = Number(data[i].putCost * data[i].outQty).toFixed(2)
  181. }
  182. }
  183. this.spinning = false
  184. return data
  185. })
  186. },
  187. rowSelectionInfo: null,
  188. // -------- 全部产品 --------
  189. productType1: [],
  190. queryParam1: {
  191. productCode: '', // 产品编码
  192. productName: '', // 产品名称
  193. productTypeSn1: '', // 产品一级分类
  194. productTypeSn2: '', // 产品二级分类
  195. productTypeSn3: '' // 产品三级分类
  196. },
  197. // 加载数据方法 必须为 Promise 对象
  198. loadData1: parameter => {
  199. this.spinning = true
  200. return stockOutDetailList(Object.assign(parameter, this.queryParam1)).then(res => {
  201. let data
  202. if (res.status == 200) {
  203. data = res.data
  204. const no = 0
  205. for (var i = 0; i < data.length; i++) {
  206. data[i].no = no + i + 1
  207. data[i].totalCost = Number(data[i].putCost * data[i].outQty).toFixed(2)
  208. }
  209. }
  210. this.spinning = false
  211. return data
  212. })
  213. }
  214. }
  215. },
  216. computed: {
  217. mtitle () {
  218. return '货架产品' + (this.baseData && this.baseData.shelfName ? this.baseData.shelfName : '')
  219. },
  220. selectTotal () {
  221. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRows.length
  222. },
  223. columns () {
  224. const arr = [
  225. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  226. { title: '库存批次', dataIndex: 'stockBatchNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  227. { title: '入库类型', dataIndex: 'putBizTypeDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  228. { title: '仓库', dataIndex: 'warehouseName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  229. { title: '仓位', dataIndex: 'warehouseLocationName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  230. // { title: '成本价', dataIndex: 'putCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  231. { title: '本次出库数量', dataIndex: 'outQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  232. // { title: '成本小计', dataIndex: 'totalCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  233. ]
  234. if (this.$hasPermissions('M_ShowAllCost')) {
  235. arr.splice(5, 0, { title: '成本价', dataIndex: 'putCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  236. arr.splice(7, 0, { title: '成本小计', dataIndex: 'totalCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  237. }
  238. return arr
  239. },
  240. columns1 () {
  241. const arr = [
  242. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  243. { title: '库存批次', dataIndex: 'stockBatchNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  244. { title: '入库类型', dataIndex: 'putBizTypeDictValue', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  245. { title: '仓库', dataIndex: 'warehouseName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  246. { title: '仓位', dataIndex: 'warehouseLocationName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  247. // { title: '成本价', dataIndex: 'putCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  248. { title: '本次出库数量', dataIndex: 'outQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  249. // { title: '成本小计', dataIndex: 'totalCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  250. ]
  251. if (this.$hasPermissions('M_ShowAllCost')) {
  252. arr.splice(5, 0, { title: '成本价', dataIndex: 'putCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  253. arr.splice(7, 0, { title: '成本小计', dataIndex: 'totalCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  254. }
  255. return arr
  256. }
  257. },
  258. methods: {
  259. cansel () {
  260. this.isShow = false
  261. },
  262. // 表格选中项
  263. rowSelectionFun (obj) {
  264. this.rowSelectionInfo = obj || null
  265. },
  266. // 产品分类 change
  267. changeProductType (val, opt) {
  268. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  269. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  270. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  271. },
  272. onStockChange (val) {
  273. console.log(val)
  274. },
  275. resetSearchForm () {
  276. this.queryParam.productCode = ''
  277. this.queryParam.productName = ''
  278. this.queryParam.productTypeSn1 = ''
  279. this.queryParam.productTypeSn2 = ''
  280. this.queryParam.productTypeSn3 = ''
  281. this.productType = []
  282. this.$refs.ruleForm.resetFields()
  283. this.$refs.table.refresh(true)
  284. },
  285. // ---------- 全部产品----------
  286. // 产品分类 change
  287. changeProductType1 (val, opt) {
  288. this.queryParam1.productTypeSn1 = val[0] ? val[0] : ''
  289. this.queryParam1.productTypeSn2 = val[1] ? val[1] : ''
  290. this.queryParam1.productTypeSn3 = val[2] ? val[2] : ''
  291. },
  292. resetSearchForm1 () {
  293. this.queryParam1.productCode = ''
  294. this.queryParam1.productName = ''
  295. this.queryParam1.productTypeSn1 = ''
  296. this.queryParam1.productTypeSn2 = ''
  297. this.queryParam1.productTypeSn3 = ''
  298. this.productType1 = []
  299. this.$refs.ruleForm1.resetFields()
  300. this.$refs.table1.refresh(true)
  301. }
  302. },
  303. watch: {
  304. // 父页面传过来的弹框状态
  305. openModal (newValue, oldValue) {
  306. this.isShow = newValue
  307. },
  308. // 重定义的弹框状态
  309. isShow (newValue, oldValue) {
  310. if (!newValue) {
  311. this.$emit('close')
  312. } else {
  313. this.$nextTick(() => {
  314. this.$refs.table.refresh(true)
  315. })
  316. }
  317. }
  318. }
  319. }
  320. </script>
  321. <style lang="less">
  322. .chooseShelf-modal {
  323. .ant-modal-body {
  324. padding: 0;
  325. .chooseShelf-modal-table{
  326. padding: 0 20px 10px;
  327. .table-operator{
  328. padding:0 10px 10px 0;
  329. display:flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. }
  333. }
  334. .table-page-search-wrapper{
  335. padding: 5px 20px 0;
  336. }
  337. }
  338. }
  339. </style>