outStockListModal.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <a-drawer
  3. :zIndex="zIndex"
  4. title="导入缺货"
  5. placement="right"
  6. :visible="isShow"
  7. :width="width"
  8. :get-container="false"
  9. :wrap-style="{ position: 'absolute' }"
  10. @close="isShow=false"
  11. wrapClassName="outStock-modal"
  12. >
  13. <a-spin :spinning="spinning" tip="Loading...">
  14. <div class="outStock-con">
  15. <div>
  16. <div ref="tableSearch" class="table-page-search-wrapper">
  17. <a-form layout="inline" @keyup.enter.native="searchForm">
  18. <a-row type="flex" :gutter="12" justify="start">
  19. <a-col :md="10" :sm="24">
  20. <a-form-model-item label="创建时间" prop="time">
  21. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  22. </a-form-model-item>
  23. </a-col>
  24. <a-col :md="8" :sm="24">
  25. <a-form-item label="采购单号">
  26. <a-input id="outStockList-purchaseBillNo" v-model.trim="queryParam.purchaseBillNo" allowClear placeholder="请输入采购单号"/>
  27. </a-form-item>
  28. </a-col>
  29. <a-col flex="auto">
  30. <a-button type="primary" @click="searchForm" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  31. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  32. </a-col>
  33. </a-row>
  34. </a-form>
  35. </div>
  36. <!-- <p style="font-weight: bold;">当前已选:{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys?rowSelectionInfo.selectedRowKeys.length:0 }}个</p> -->
  37. <!-- 列表 -->
  38. <s-table
  39. class="sTable"
  40. ref="table"
  41. size="small"
  42. :rowKey="(record) => record.purchaseBillSn"
  43. rowKeyName="purchaseBillSn"
  44. :row-selection="{ columnWidth: 40 }"
  45. @rowSelection="rowSelectionFun"
  46. :data="loadData"
  47. :columns="columns"
  48. :style="{ height: tableHeight+84.5+'px' }"
  49. :scroll="{ y:tableHeight, x: 1000 }"
  50. bordered>
  51. </s-table>
  52. </div>
  53. <!-- 按钮 -->
  54. <div class="btn-con" ref="btnBox">
  55. <a-button
  56. id="outStock-cancel"
  57. size="large"
  58. class="button-cancel"
  59. @click="isShow=false"
  60. style="padding: 0 30px;margin-right: 30px;">取消</a-button>
  61. <a-button
  62. type="primary"
  63. id="outStock-save"
  64. size="large"
  65. class="button-primary"
  66. @click="handleSave"
  67. style="padding: 0 30px;">确定</a-button>
  68. </div>
  69. </div>
  70. </a-spin>
  71. </a-drawer>
  72. </template>
  73. <script>
  74. import { commonMixin } from '@/utils/mixin'
  75. import { STable } from '@/components'
  76. import { outOfStockList } from '@/api/oos'
  77. import ProductType from '../../common/productType.js'
  78. import ProductBrand from '../../common/productBrand.js'
  79. import rangeDate from '@/views/common/rangeDate.vue'
  80. import getDate from '@/libs/getDate.js'
  81. export default {
  82. name: 'OutStockModal',
  83. components: { STable, ProductType, ProductBrand, rangeDate, getDate },
  84. mixins: [commonMixin],
  85. props: {
  86. openModal: { // 弹框显示状态
  87. type: Boolean,
  88. default: false
  89. },
  90. chooseData: {
  91. type: Array,
  92. default: () => {
  93. return []
  94. }
  95. },
  96. paramsData: {
  97. type: Object,
  98. default: () => {
  99. return {}
  100. }
  101. }
  102. },
  103. data () {
  104. const _this = this
  105. return {
  106. isShow: this.openModal, // 是否打开弹框
  107. zIndex: 90,
  108. width: '70%',
  109. tableHeight: 0,
  110. formItemLayout: {
  111. labelCol: { span: 4 },
  112. wrapperCol: { span: 20 }
  113. },
  114. disabled: false, // 查询、重置按钮是否可操作
  115. columns: [
  116. { title: '序号', dataIndex: 'no', width: '8%', align: 'center' },
  117. { title: '创建时间', dataIndex: 'createDate', width: '30%', align: 'center', customRender: function (text) { return text || '--' } },
  118. { title: '采购单号', dataIndex: 'purchaseBillNo', width: '20%', align: 'center', customRender: function (text) { return text || '--' } },
  119. { title: '缺货款数', dataIndex: 'totalCategory', width: '16%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  120. { title: '缺货数量', dataIndex: 'totalQty', width: '16%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  121. { title: '缺货金额', dataIndex: 'totalAmount', width: '16%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text, 2) : '--') } }
  122. ],
  123. // 加载数据方法 必须为 Promise 对象
  124. loadData: parameter => {
  125. this.disabled = true
  126. this.spinning = true
  127. return outOfStockList(Object.assign(parameter, this.queryParam)).then(res => {
  128. let data
  129. if (res.status == 200) {
  130. data = res.data
  131. const no = (data.pageNo - 1) * data.pageSize
  132. for (var i = 0; i < data.list.length; i++) {
  133. data.list[i].no = no + i + 1
  134. }
  135. this.disabled = false
  136. }
  137. this.spinning = false
  138. return data
  139. })
  140. },
  141. spinning: false,
  142. rowSelectionInfo: null,
  143. time: [
  144. getDate.getCurrMonthDays().starttime,
  145. getDate.getCurrMonthDays().endtime
  146. ],
  147. queryParam: { // 查询条件
  148. purchaseBillNo: '',
  149. beginDate: getDate.getCurrMonthDays().starttime,
  150. endDate: getDate.getCurrMonthDays().endtime
  151. }
  152. }
  153. },
  154. methods: {
  155. // 时间 change
  156. dateChange (date) {
  157. this.queryParam.beginDate = date[0]
  158. this.queryParam.endDate = date[1]
  159. },
  160. // 表格选中项
  161. rowSelectionFun (obj) {
  162. this.rowSelectionInfo = obj || null
  163. },
  164. // 保存
  165. handleSave () {
  166. const _this = this
  167. if (!this.rowSelectionInfo || (this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  168. this.$message.warning('请在列表勾选后再进行操作!')
  169. return
  170. }
  171. _this.$emit('ok', this.rowSelectionInfo.selectedRowKeys)
  172. },
  173. searchForm () {
  174. this.$refs.table.refresh(true)
  175. },
  176. resetSearchForm () {
  177. this.$refs.rangeDate.resetDate(this.time)
  178. this.queryParam.beginDate = getDate.getCurrMonthDays().starttime
  179. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  180. this.queryParam.purchaseBillNo = ''
  181. this.$refs.table.refresh(true)
  182. },
  183. setTableH () {
  184. this.$nextTick(() => {
  185. const searchBoxH = this.$refs.tableSearch.offsetHeight
  186. const tabBoxH = this.$refs.btnBox.offsetHeight
  187. this.tableHeight = window.innerHeight - searchBoxH - tabBoxH - 300
  188. })
  189. }
  190. },
  191. watch: {
  192. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  193. this.setTableH()
  194. },
  195. // 父页面传过来的弹框状态
  196. openModal (newValue, oldValue) {
  197. this.isShow = newValue
  198. },
  199. // 重定义的弹框状态
  200. isShow (newValue, oldValue) {
  201. if (!newValue) {
  202. this.$refs.table.clearSelected() // 清空表格选中项
  203. this.$emit('close')
  204. } else {
  205. setTimeout(() => {
  206. this.setTableH()
  207. }, 200)
  208. this.resetSearchForm()
  209. }
  210. }
  211. }
  212. }
  213. </script>
  214. <style lang="less" scoped>
  215. .outStock-modal{
  216. .outStock-con{
  217. .btn-con{
  218. text-align: center;
  219. margin: 30px 0 20px;
  220. .button-cancel{
  221. font-size: 12px;
  222. }
  223. }
  224. }
  225. }
  226. </style>