detailList.vue 12 KB

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