list.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <a-card size="small" :bordered="false" class="warehouseList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div class="table-page-search-wrapper" ref="tableSearch">
  6. <a-form-model
  7. id="inventoryImport-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. @keyup.enter.native="handleSearch" >
  16. <a-row :gutter="15">
  17. <a-col :md="8" :sm="24">
  18. <a-form-model-item label="导入时间" prop="time">
  19. <rangeDate ref="rangeDate" @change="dateChange" />
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :md="6" :sm="24">
  23. <a-form-item label="导入单号">
  24. <a-input id="inventoryImport-no" v-model.trim="queryParam.stockImportNo" allowClear placeholder="请输入导入单号"/>
  25. </a-form-item>
  26. </a-col>
  27. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  28. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="inventoryImport-refresh">查询</a-button>
  29. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="inventoryImport-reset">重置</a-button>
  30. </a-col>
  31. </a-row>
  32. </a-form-model>
  33. </div>
  34. <!-- 导入按钮 -->
  35. <div class="table-operator">
  36. <a-button id="inventoryImport-add" type="primary" class="button-error" v-if="$hasPermissions('B_importContent')" @click="openGuideModal=true">库存导入</a-button>
  37. </div>
  38. <!-- 合计 -->
  39. <a-alert type="info" style="margin-bottom:10px">
  40. <div class="ftext" slot="message">
  41. 总单数:<strong>{{ (totalData && (totalData.totalRowSize || totalData.totalRowSize==0)) ? totalData.totalRowSize : '--' }}</strong>;
  42. 产品总数量:<strong>{{ (totalData && (totalData.productTotalQty || totalData.productTotalQty==0)) ? totalData.productTotalQty : '--' }}</strong>;
  43. <div v-if="$hasPermissions('M_ShowAllCost')" style="display: inline-block;">
  44. 总成本:<strong>{{ (totalData && (totalData.productTotalCost || totalData.productTotalCost==0)) ? toThousands(totalData.productTotalCost) : '--' }}</strong>。
  45. </div>
  46. </div>
  47. </a-alert>
  48. <!-- 列表 -->
  49. <s-table
  50. class="sTable"
  51. ref="table"
  52. size="small"
  53. :style="{ height: tableHeight+84.5+'px' }"
  54. :rowKey="(record) => record.stockImportSn"
  55. rowKeyName="stockImportSn"
  56. :columns="columns"
  57. :data="loadData"
  58. :defaultLoadData="false"
  59. bordered>
  60. <!-- 导入单号 -->
  61. <template slot="stockImportNo" slot-scope="text, record">
  62. <span class="table-td-link" v-if="$hasPermissions('B_inventoryImport-detail')" @click="handleDetail(record)">{{ record.stockImportNo }}</span>
  63. <span v-else>{{ record.stockImportNo || '--' }}</span>
  64. </template>
  65. </s-table>
  66. </a-spin>
  67. <!-- 库存导入 -->
  68. <importGuideModal :openModal="openGuideModal" @close="openGuideModal=false" @ok="hanldeImprotOk" />
  69. <!-- 库存导入详情 -->
  70. <a-modal
  71. centered
  72. class="chooseImport-modal"
  73. :footer="null"
  74. title="库存导入明细"
  75. v-model="openInventoryImportDetail"
  76. @cancel="openInventoryImportDetail=false;detailSn=undefined;"
  77. width="70%">
  78. <detailList ref="inventoryImportDeail" typeInfo="STOCK_IMPORT" :detailSn="detailSn"></detailList>
  79. </a-modal>
  80. </a-card>
  81. </template>
  82. <script>
  83. import { commonMixin } from '@/utils/mixin'
  84. import { STable, VSelect } from '@/components'
  85. import rangeDate from '@/views/common/rangeDate.vue'
  86. import getDate from '@/libs/getDate.js'
  87. import importGuideModal from './importGuideModal.vue'
  88. import detailList from './detailList.vue'
  89. import { stockImportAllList, stockImportCount } from '@/api/stockImport'
  90. export default {
  91. components: { STable, VSelect, rangeDate, importGuideModal, detailList },
  92. mixins: [commonMixin],
  93. data () {
  94. return {
  95. spinning: false,
  96. labelCol: { span: 8 },
  97. wrapperCol: { span: 16 },
  98. tableHeight: 0,
  99. queryParam: { // 查询条件
  100. time: [
  101. getDate.getThreeMonthDays().starttime,
  102. getDate.getCurrMonthDays().endtime
  103. ],
  104. beginDate: '',
  105. endDate: '',
  106. stockImportNo: undefined,
  107. importType: 'STOCK_IMPORT'
  108. },
  109. openGuideModal: false,
  110. detailSn: undefined,
  111. openInventoryImportDetail: false,
  112. rules: {
  113. 'time': [{ required: true, message: '请选择导入时间', trigger: 'change' }]
  114. },
  115. disabled: false, // 查询、重置按钮是否可操作
  116. exportLoading: false,
  117. // 加载数据方法 必须为 Promise 对象
  118. loadData: parameter => {
  119. this.disabled = true
  120. const params = Object.assign(parameter, this.queryParam)
  121. this.spinning = true
  122. delete params.time
  123. return stockImportAllList(params).then(res => {
  124. let data
  125. if (res.status == 200) {
  126. data = res.data
  127. // 总计
  128. this.getCount(params)
  129. const no = (data.pageNo - 1) * data.pageSize
  130. for (var i = 0; i < data.list.length; i++) {
  131. data.list[i].no = no + i + 1
  132. }
  133. this.disabled = false
  134. }
  135. this.spinning = false
  136. return data
  137. })
  138. },
  139. totalData: null // 合计
  140. }
  141. },
  142. computed: {
  143. columns () {
  144. const _this = this
  145. const arr = [
  146. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  147. { title: '导入时间', dataIndex: 'importTime', width: '21%', align: 'center', customRender: function (text) { return text || '--' } },
  148. { title: '导入单号', dataIndex: 'stockImportNo', width: '18%', align: 'center', scopedSlots: { customRender: 'stockImportNo' } },
  149. { title: '款数', dataIndex: 'productTotalCategory', width: '18%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '数量', dataIndex: 'productTotalQty', width: '18%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  151. // { title: '成本', dataIndex: 'totalCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  152. ]
  153. if (this.$hasPermissions('M_ShowAllCost')) {
  154. arr.splice(5, 0, { title: '成本', dataIndex: 'productTotalCost', width: '20%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  155. }
  156. return arr
  157. }
  158. },
  159. methods: {
  160. // 详情
  161. handleDetail (row) {
  162. this.openInventoryImportDetail = true
  163. this.detailSn = row.stockImportNo
  164. this.$nextTick(() => {
  165. this.$refs.inventoryImportDeail.handleSearch()
  166. })
  167. },
  168. // 合计
  169. getCount (params) {
  170. stockImportCount(params).then(res => {
  171. if (res.status == 200) {
  172. this.totalData = res.data
  173. } else {
  174. this.totalData = null
  175. }
  176. })
  177. },
  178. // 创建时间 change
  179. dateChange (date) {
  180. this.queryParam.time = date
  181. this.queryParam.beginDate = date[0] || ''
  182. this.queryParam.endDate = date[1] || ''
  183. },
  184. // 查询
  185. handleSearch () {
  186. this.$refs.ruleForm.validate(valid => {
  187. if (valid) {
  188. this.$refs.table.refresh(true)
  189. } else {
  190. console.log('error submit!!')
  191. return false
  192. }
  193. })
  194. },
  195. // 库存导入
  196. hanldeImprotOk () {
  197. this.$refs.table.refresh(true)
  198. },
  199. // 重置
  200. resetSearchForm (flag) {
  201. this.queryParam.time = [
  202. getDate.getThreeMonthDays().starttime,
  203. getDate.getCurrMonthDays().endtime
  204. ]
  205. this.$refs.rangeDate.resetDate(this.queryParam.time)
  206. this.queryParam.beginDate = getDate.getThreeMonthDays().starttime
  207. this.queryParam.endDate = getDate.getCurrMonthDays().endtime
  208. this.$refs.ruleForm.resetFields()
  209. this.queryParam.stockImportNo = undefined
  210. this.totalData = null
  211. this.$refs.table.clearTable()
  212. this.handleSearch()
  213. },
  214. setTableH () {
  215. const tableSearchH = this.$refs.tableSearch.offsetHeight
  216. this.tableHeight = window.innerHeight - tableSearchH - 276
  217. },
  218. pageInit () {
  219. const _this = this
  220. this.$nextTick(() => { // 页面渲染完成后的回调
  221. _this.setTableH()
  222. })
  223. }
  224. },
  225. watch: {
  226. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  227. this.setTableH()
  228. }
  229. },
  230. mounted () {
  231. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  232. this.pageInit()
  233. this.resetSearchForm()
  234. }
  235. },
  236. activated () {
  237. // 如果是新页签打开,则重置当前页面
  238. if (this.$store.state.app.isNewTab) {
  239. this.pageInit()
  240. this.resetSearchForm()
  241. }
  242. },
  243. beforeRouteEnter (to, from, next) {
  244. next(vm => {})
  245. }
  246. }
  247. </script>