list.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="bulkIn-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="bulkIn-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="bulkIn-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="bulkIn-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. </template>
  44. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  45. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="bulkIn-refresh">查询</a-button>
  46. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="bulkIn-reset">重置</a-button>
  47. <a-button
  48. type="primary"
  49. style="margin-left: 5px"
  50. @click="handleExport"
  51. :disabled="disabled"
  52. :loading="exportLoading"
  53. v-if="$hasPermissions('M_bulkWarehousingReportExport')"
  54. class="button-warning"
  55. id="bulkIn-export-btn">导出</a-button>
  56. <a @click="advanced=!advanced" style="margin-left: 5px">
  57. {{ advanced ? '收起' : '展开' }}
  58. <a-icon :type="advanced ? 'up' : 'down'"/>
  59. </a>
  60. </a-col>
  61. </a-row>
  62. </a-form-model>
  63. </div>
  64. <!-- 合计 -->
  65. <a-alert type="info" style="margin-bottom:10px">
  66. <div class="ftext" slot="message">
  67. 总单数:<strong>{{ (totalData && (totalData.totalRowSize || totalData.totalRowSize==0)) ? totalData.totalRowSize : '--' }}</strong>;
  68. 产品总数量:<strong>{{ (totalData && (totalData.productTotalQty || totalData.productTotalQty==0)) ? totalData.productTotalQty : '--' }}</strong>;
  69. <div v-if="$hasPermissions('M_ShowAllCost')" style="display: inline-block;">
  70. 散件总成本:<strong>{{ (totalData && (totalData.productTotalCost || totalData.productTotalCost==0)) ? toThousands(totalData.productTotalCost) : '--' }}</strong>;
  71. </div>
  72. </div>
  73. </a-alert>
  74. <!-- 列表 -->
  75. <s-table
  76. class="sTable"
  77. ref="table"
  78. size="small"
  79. :rowKey="(record) => record.id"
  80. :columns="columns"
  81. :data="loadData"
  82. :defaultLoadData="false"
  83. bordered>
  84. </s-table>
  85. </a-spin>
  86. </template>
  87. <script>
  88. import { commonMixin } from '@/utils/mixin'
  89. import { STable, VSelect } from '@/components'
  90. import rangeDate from '@/views/common/rangeDate.vue'
  91. import { downloadExcel } from '@/libs/JGPrint.js'
  92. import { sparePartsPutTypeAllList } from '@/api/sparePartsPutType'
  93. import supplier from '@/views/common/supplier'
  94. import { reportBlukPageList, reportBlukTotal, reportBlukExport } from '@/api/reportData'
  95. export default {
  96. components: { STable, VSelect, rangeDate, supplier },
  97. mixins: [commonMixin],
  98. data () {
  99. return {
  100. spinning: false,
  101. labelCol: { span: 8 },
  102. wrapperCol: { span: 16 },
  103. advanced: false, // 高级搜索 展开/关闭
  104. tableHeight: 0,
  105. queryParam: { // 查询条件
  106. time: [],
  107. beginDate: '',
  108. endDate: '',
  109. sparePartsType: undefined,
  110. supplierSn: undefined,
  111. sparePartsPurchaseNo: '',
  112. supplierName: ''
  113. },
  114. rules: {
  115. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  116. },
  117. disabled: false, // 查询、重置按钮是否可操作
  118. exportLoading: false,
  119. // 加载数据方法 必须为 Promise 对象
  120. loadData: parameter => {
  121. this.disabled = true
  122. const params = Object.assign(parameter, this.queryParam)
  123. this.spinning = true
  124. delete params.time
  125. return reportBlukPageList(params).then(res => {
  126. let data
  127. if (res.status == 200) {
  128. data = res.data
  129. // 总计
  130. this.getCount(params)
  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. totalData: null, // 合计
  142. sparePartsPutTypeList: [] // 散件入库类型
  143. }
  144. },
  145. computed: {
  146. columns () {
  147. const _this = this
  148. const arr = [
  149. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  150. { title: '散件单号', dataIndex: 'sparePartsPurchaseNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  151. { title: '供应商', dataIndex: 'supplierName', width: '15%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  152. { title: '散件入库类型', dataIndex: 'sparePartsTypeName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  153. { title: '款数', dataIndex: 'productTotalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  154. { title: '数量', dataIndex: 'productTotalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  155. // { title: '成本', dataIndex: 'productTotalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  156. { title: '审核时间', dataIndex: 'auditTime', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  157. ]
  158. if (this.$hasPermissions('M_ShowAllCost')) {
  159. arr.splice(6, 0, { title: '成本', dataIndex: 'productTotalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  160. }
  161. return arr
  162. }
  163. },
  164. methods: {
  165. // 合计
  166. getCount (params) {
  167. reportBlukTotal(params).then(res => {
  168. if (res.status == 200) {
  169. this.totalData = res.data
  170. } else {
  171. this.totalData = null
  172. }
  173. })
  174. },
  175. // 创建时间 change
  176. dateChange (date) {
  177. this.queryParam.time = date
  178. this.queryParam.beginDate = date[0] || ''
  179. this.queryParam.endDate = date[1] || ''
  180. },
  181. // 查询
  182. handleSearch () {
  183. this.$refs.ruleForm.validate(valid => {
  184. if (valid) {
  185. this.$refs.table.refresh(true)
  186. } else {
  187. console.log('error submit!!')
  188. return false
  189. }
  190. })
  191. },
  192. // 重置
  193. resetSearchForm () {
  194. this.$refs.rangeDate.resetDate()
  195. this.queryParam.time = []
  196. this.queryParam.beginDate = ''
  197. this.queryParam.endDate = ''
  198. this.queryParam.supplierSn = undefined
  199. this.queryParam.sparePartsType = undefined
  200. this.queryParam.sparePartsPurchaseNo = ''
  201. this.queryParam.supplierName = ''
  202. this.$refs.ruleForm.resetFields()
  203. this.totalData = null
  204. this.$refs.table.clearTable()
  205. },
  206. // 导出
  207. handleExport () {
  208. const _this = this
  209. this.$refs.ruleForm.validate(valid => {
  210. if (valid) {
  211. const params = _this.queryParam
  212. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  213. _this.exportLoading = true
  214. _this.spinning = true
  215. reportBlukExport(params).then(res => {
  216. downloadExcel(res, '散件入库报表')
  217. _this.exportLoading = false
  218. _this.spinning = false
  219. })
  220. } else {
  221. console.log('error submit!!')
  222. return false
  223. }
  224. })
  225. },
  226. // 散件入库类型下拉数据
  227. getSparePartsPutTypeList () {
  228. sparePartsPutTypeAllList().then(res => {
  229. if (res.status == 200) {
  230. this.sparePartsPutTypeList = res.data
  231. } else {
  232. this.sparePartsPutTypeList = []
  233. }
  234. })
  235. },
  236. pageInit () {
  237. this.getSparePartsPutTypeList()
  238. }
  239. },
  240. mounted () {
  241. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  242. this.pageInit()
  243. this.resetSearchForm()
  244. }
  245. },
  246. activated () {
  247. // 如果是新页签打开,则重置当前页面
  248. if (this.$store.state.app.isNewTab) {
  249. this.pageInit()
  250. this.resetSearchForm()
  251. }
  252. },
  253. beforeRouteEnter (to, from, next) {
  254. next(vm => {})
  255. }
  256. }
  257. </script>