detailList.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="salesDetailReportList-form"
  7. ref="ruleForm"
  8. class="form-model-con"
  9. layout="inline"
  10. :model="queryParam"
  11. :rules="rules"
  12. :labelCol="labelCol"
  13. :wrapperCol="wrapperCol"
  14. @keyup.enter.native="handleSearch" >
  15. <a-row :gutter="15">
  16. <a-col :md="6" :sm="24">
  17. <a-form-model-item label="导入单号">
  18. <a-input v-model.trim="queryParam.stockImportNo" allowClear placeholder="请输入导入单号"/>
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :md="6" :sm="24">
  22. <a-form-model-item label="导入类型">
  23. <a-select
  24. placeholder="请选择导入类型"
  25. v-model="queryParam.importType">
  26. <a-select-option value="STOCK_IMPORT">
  27. 库存导入
  28. </a-select-option>
  29. <a-select-option value="SPARE_PARTS_IMPORT">
  30. 散件导入
  31. </a-select-option>
  32. </a-select>
  33. </a-form-model-item>
  34. </a-col>
  35. <a-col :md="6" :sm="24">
  36. <a-form-model-item label="供应商">
  37. <supplier
  38. v-model="supplierSn"
  39. placeholder="请选择供应商"
  40. @change="supplierChange"
  41. ></supplier>
  42. </a-form-model-item>
  43. </a-col>
  44. <template v-if="advanced">
  45. <a-col :md="6" :sm="24">
  46. <a-form-model-item label="产品编码">
  47. <a-input v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
  48. </a-form-model-item>
  49. </a-col>
  50. <a-col :md="6" :sm="24">
  51. <a-form-model-item label="产品名称">
  52. <a-input v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
  53. </a-form-model-item>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-form-item label="产品品牌">
  57. <ProductBrand placeholder="请选择产品品牌" v-model="queryParam.productEntity.productBrandSn"></ProductBrand>
  58. </a-form-item>
  59. </a-col>
  60. <a-col :md="6" :sm="24">
  61. <a-form-model-item label="产品分类">
  62. <ProductType placeholder="请选择产品分类" :isDealer="true" @change="changeProductType" v-model="queryParam.productType"></ProductType>
  63. </a-form-model-item>
  64. </a-col>
  65. <a-col :md="6" :sm="24">
  66. <a-form-model-item label="导入时间">
  67. <rangeDate ref="rangeDate" @change="dateChange" />
  68. </a-form-model-item>
  69. </a-col>
  70. </template>
  71. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  72. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="salesDetailReportList-refresh">查询</a-button>
  73. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="salesDetailReportList-reset">重置</a-button>
  74. <a-button
  75. type="primary"
  76. style="margin-left: 5px"
  77. @click="handleExport"
  78. :disabled="disabled"
  79. :loading="exportLoading"
  80. v-if="$hasPermissions('B_StockImportDetailExport')"
  81. class="button-warning"
  82. id="salesDetailReportList-export-btn">导出</a-button>
  83. <a @click="advanced=!advanced" style="margin-left: 5px">
  84. {{ advanced ? '收起' : '展开' }}
  85. <a-icon :type="advanced ? 'up' : 'down'"/>
  86. </a>
  87. </a-col>
  88. </a-row>
  89. </a-form-model>
  90. </div>
  91. <!-- 合计 -->
  92. <a-alert type="info" style="margin-bottom:10px">
  93. <div class="ftext" slot="message">
  94. 产品总数量:<strong>{{ (totalData && (totalData.putQty || totalData.putQty==0)) ? totalData.putQty : '--' }}</strong>;
  95. <div v-if="$hasPermissions('M_ShowAllCost')" style="display: inline-block;">
  96. 总成本:<strong>{{ (totalData && (totalData.cost || totalData.cost==0)) ? toThousands(totalData.cost) : '--' }}</strong>。
  97. </div>
  98. </div>
  99. </a-alert>
  100. <!-- 列表 -->
  101. <s-table
  102. class="sTable"
  103. ref="table"
  104. size="small"
  105. :rowKey="(record) => record.id"
  106. :columns="columns"
  107. :data="loadData"
  108. :defaultLoadData="false"
  109. bordered>
  110. </s-table>
  111. </a-spin>
  112. </template>
  113. <script>
  114. import { commonMixin } from '@/utils/mixin'
  115. import { STable, VSelect } from '@/components'
  116. import rangeDate from '@/views/common/rangeDate.vue'
  117. import { downloadExcel } from '@/libs/JGPrint.js'
  118. import ProductType from '../../common/productType.js'
  119. import ProductBrand from '../../common/productBrand.js'
  120. import supplier from '@/views/common/supplier'
  121. import { reportStockImportDetailList, reportStockImportDetailCount, reportStockImportDetailExport } from '@/api/reportData'
  122. export default {
  123. components: { STable, VSelect, rangeDate, ProductType, ProductBrand, supplier },
  124. mixins: [commonMixin],
  125. data () {
  126. return {
  127. spinning: false,
  128. labelCol: { span: 8 },
  129. wrapperCol: { span: 16 },
  130. advanced: false, // 高级搜索 展开/关闭
  131. tableHeight: 0,
  132. supplierSn: undefined,
  133. queryParam: { // 查询条件
  134. time: [],
  135. beginDate: '',
  136. endDate: '',
  137. productType: undefined,
  138. importType: undefined,
  139. productEntity: {
  140. productBrandSn: undefined, // 产品品牌
  141. productTypeSn1: '', // 产品一级分类
  142. productTypeSn2: '', // 产品二级分类
  143. productTypeSn3: '', // 产品三级分类
  144. code: '', // 产品编码
  145. name: '' // 产品名称
  146. },
  147. stockImportNo: '',
  148. supplierName: ''
  149. },
  150. rules: {
  151. 'time': [{ required: true, message: '请选择导入时间', trigger: 'change' }]
  152. },
  153. disabled: false, // 查询、重置按钮是否可操作
  154. exportLoading: false,
  155. // 加载数据方法 必须为 Promise 对象
  156. loadData: parameter => {
  157. this.disabled = true
  158. const params = Object.assign(parameter, this.queryParam)
  159. this.spinning = true
  160. delete params.time
  161. return reportStockImportDetailList(params).then(res => {
  162. let data
  163. if (res.status == 200) {
  164. data = res.data
  165. // 总计
  166. this.getCount(params)
  167. const no = (data.pageNo - 1) * data.pageSize
  168. for (var i = 0; i < data.list.length; i++) {
  169. data.list[i].no = no + i + 1
  170. data.list[i].inStockQty = data.list[i].qty
  171. }
  172. this.disabled = false
  173. }
  174. this.spinning = false
  175. return data
  176. })
  177. },
  178. totalData: null // 合计
  179. }
  180. },
  181. computed: {
  182. columns () {
  183. const _this = this
  184. const arr = [
  185. { title: '序号', dataIndex: 'no', width: '5%', align: 'center' },
  186. { title: '导入单号', dataIndex: 'stockImportNo', width: '12%', align: 'center', customRender: function (text) { return text || '--' } },
  187. { title: '导入类型', dataIndex: 'importTypeDictValue', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  188. { title: '供应商', dataIndex: 'supplierName', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  189. { title: '产品编码', dataIndex: 'productCode', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  190. { title: '产品名称', dataIndex: 'productName', width: '12%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  191. { title: '单位', dataIndex: 'unit', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  192. { title: '数量', dataIndex: 'putQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  193. // { title: '成本', dataIndex: 'cost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  194. { title: '仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  195. { title: '仓位', dataIndex: 'warehouseLocationName', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  196. { title: '导入时间', dataIndex: 'importTime', width: '12%', align: 'center', customRender: function (text) { return text || '--' } }
  197. ]
  198. if (this.$hasPermissions('M_ShowAllCost')) {
  199. arr.splice(8, 0, { title: '成本', dataIndex: 'cost', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  200. }
  201. return arr
  202. }
  203. },
  204. methods: {
  205. supplierChange (val, row) {
  206. this.queryParam.supplierName = row ? row.supplierName : ''
  207. },
  208. // 合计
  209. getCount (params) {
  210. reportStockImportDetailCount(params).then(res => {
  211. if (res.status == 200) {
  212. this.totalData = res.data
  213. } else {
  214. this.totalData = null
  215. }
  216. })
  217. },
  218. // 创建时间 change
  219. dateChange (date) {
  220. this.queryParam.time = date
  221. this.queryParam.beginDate = date[0] || ''
  222. this.queryParam.endDate = date[1] || ''
  223. },
  224. // 查询
  225. handleSearch () {
  226. this.$refs.ruleForm.validate(valid => {
  227. if (valid) {
  228. this.$refs.table.refresh(true)
  229. } else {
  230. console.log('error submit!!')
  231. return false
  232. }
  233. })
  234. },
  235. // 重置
  236. resetSearchForm () {
  237. if (this.advanced) {
  238. this.$refs.rangeDate.resetDate()
  239. }
  240. this.supplierSn = undefined
  241. this.queryParam.time = []
  242. this.queryParam.beginDate = ''
  243. this.queryParam.endDate = ''
  244. this.queryParam.stockImportNo = ''
  245. this.queryParam.supplierName = ''
  246. this.queryParam.importType = undefined
  247. this.queryParam.productEntity.productBrandSn = undefined
  248. this.queryParam.productEntity.productTypeSn1 = ''
  249. this.queryParam.productEntity.productTypeSn2 = ''
  250. this.queryParam.productEntity.productTypeSn3 = ''
  251. this.queryParam.productEntity.code = ''
  252. this.queryParam.productEntity.name = ''
  253. this.queryParam.productType = []
  254. this.productType = []
  255. this.$refs.ruleForm.resetFields()
  256. this.totalData = null
  257. this.$refs.table.clearTable()
  258. },
  259. // 导出
  260. handleExport () {
  261. const _this = this
  262. this.$refs.ruleForm.validate(valid => {
  263. if (valid) {
  264. const params = _this.queryParam
  265. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  266. _this.exportLoading = true
  267. _this.spinning = true
  268. reportStockImportDetailExport(params).then(res => {
  269. downloadExcel(res, '库存导入明细报表')
  270. _this.exportLoading = false
  271. _this.spinning = false
  272. })
  273. } else {
  274. console.log('error submit!!')
  275. return false
  276. }
  277. })
  278. },
  279. // 产品分类 change
  280. changeProductType (val, opt) {
  281. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  282. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  283. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  284. },
  285. pageInit () {
  286. this.disabled = false
  287. this.spinning = false
  288. }
  289. },
  290. mounted () {
  291. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  292. this.pageInit()
  293. this.resetSearchForm()
  294. }
  295. },
  296. activated () {
  297. // 如果是新页签打开,则重置当前页面
  298. if (this.$store.state.app.isNewTab) {
  299. this.pageInit()
  300. this.resetSearchForm()
  301. }
  302. },
  303. beforeRouteEnter (to, from, next) {
  304. next(vm => {})
  305. }
  306. }
  307. </script>