list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <template>
  2. <a-spin :spinning="spinning" tip="Loading...">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="storeTransOutReport-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 id="storeTransOutReport-time" 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="storeTransOutReport-storeCallOutNo" v-model.trim="queryParam.storeCallOutNo" allowClear placeholder="请输入店内调出单号"/>
  24. </a-form-model-item>
  25. </a-col>
  26. <a-col :md="6" :sm="24">
  27. <a-form-item label="调往对象">
  28. <custList id="storeTransOutReport-putPersonName" ref="custList" @change="custChange"></custList>
  29. </a-form-item>
  30. </a-col>
  31. <a-col :md="6" :sm="24">
  32. <a-form-item label="调拨类型">
  33. <a-select id="sstoreTransOutReport-callOutType" v-model="queryParam.callOutType" placeholder="请选择调拨类型" allowClear >
  34. <a-select-option v-for="item in storeCallOutTypeList" :id="item.storeCallOutTypeSn" :key="item.storeCallOutTypeSn" :value="item.storeCallOutTypeSn">{{ item.name }}</a-select-option>
  35. </a-select>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-item label="出库时间">
  40. <rangeDate id="storeTransOutReport-outWareTime" ref="outWareRangeDate" :value="outWareTime" @change="outWareDateChange" />
  41. </a-form-item>
  42. </a-col>
  43. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  44. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="storeTransOutReport-refresh">查询</a-button>
  45. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="storeTransOutReport-reset">重置</a-button>
  46. <a-button
  47. type="primary"
  48. style="margin-left: 5px"
  49. @click="handleExport"
  50. :disabled="disabled"
  51. :loading="exportLoading"
  52. v-if="$hasPermissions('M_storeTransferOutReportExport')"
  53. class="button-warning"
  54. id="storeTransOutReport-export-btn">导出</a-button>
  55. </a-col>
  56. </a-row>
  57. </a-form-model>
  58. </div>
  59. <!-- 合计 -->
  60. <a-alert type="info" style="margin-bottom:10px">
  61. <div class="ftext" slot="message">
  62. 总单数:<strong>{{ (totalData && (totalData.productTotalCategory || totalData.productTotalCategory==0)) ? totalData.productTotalCategory : '--' }}</strong>;
  63. 产品总数量:<strong>{{ (totalData && (totalData.productTotalQty || totalData.productTotalQty==0)) ? totalData.productTotalQty : '--' }}</strong>;
  64. <div v-if="$hasPermissions('M_ShowAllCost')" style="display: inline-block;">
  65. 调出总成本:<strong>{{ (totalData && (totalData.productTotalCost || totalData.productTotalCost==0)) ? toThousands(totalData.productTotalCost) : '--' }}</strong>;
  66. </div>
  67. </div>
  68. </a-alert>
  69. <!-- 列表 -->
  70. <s-table
  71. class="sTable"
  72. ref="table"
  73. size="small"
  74. :rowKey="(record) => record.id"
  75. :columns="columns"
  76. :data="loadData"
  77. :defaultLoadData="false"
  78. bordered>
  79. </s-table>
  80. </a-spin>
  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 { downloadExcel } from '@/libs/JGPrint.js'
  87. import custList from '@/views/common/custList.vue'
  88. import { storeCallOutTypeAllList } from '@/api/storeCallOutType'
  89. import { reportStoreCallOutPageList, reportStoreCallOutListTotal, reportStoreCallOutExport } from '@/api/reportData'
  90. export default {
  91. components: { STable, VSelect, rangeDate, custList },
  92. mixins: [commonMixin],
  93. data () {
  94. return {
  95. spinning: false,
  96. labelCol: { span: 8 },
  97. wrapperCol: { span: 16 },
  98. advanced: false, // 高级搜索 展开/关闭
  99. tableHeight: 0,
  100. outWareTime: [], // 出库时间
  101. queryParam: { // 查询条件
  102. time: [],
  103. beginDate: '', // 开始时间
  104. endDate: '', // 结束时间
  105. customerNameCurrent: undefined, // 调往对象
  106. customerSnCurrent: undefined, // 调往对象sn
  107. callOutType: undefined, // 调拨类型
  108. storeCallOutNo: ''// 调拨单号
  109. },
  110. rules: {
  111. 'time': [{ required: true, message: '请选择审核时间', trigger: 'change' }]
  112. },
  113. disabled: false, // 查询、重置按钮是否可操作
  114. exportLoading: false,
  115. // 加载数据方法 必须为 Promise 对象
  116. loadData: parameter => {
  117. this.disabled = true
  118. const params = Object.assign(parameter, this.queryParam)
  119. this.spinning = true
  120. delete params.time
  121. return reportStoreCallOutPageList(params).then(res => {
  122. let data
  123. if (res.status == 200) {
  124. data = res.data
  125. // 总计
  126. this.getCount(params)
  127. const no = (data.pageNo - 1) * data.pageSize
  128. for (var i = 0; i < data.list.length; i++) {
  129. data.list[i].no = no + i + 1
  130. }
  131. this.disabled = false
  132. }
  133. this.spinning = false
  134. return data
  135. })
  136. },
  137. totalData: null, // 合计
  138. storeCallOutTypeList: [] // 调拨类型
  139. }
  140. },
  141. computed: {
  142. columns () {
  143. const _this = this
  144. const arr = [
  145. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  146. { title: '店内调出单号', dataIndex: 'storeCallOutNo', width: '15%', align: 'center', customRender: function (text) { return text || '--' } },
  147. { title: '调往对象', width: '15%', align: 'center', customRender: function (text, record) { return record.putPersonName || '--' }, ellipsis: true },
  148. { title: '调拨类型', dataIndex: 'callOutTypeName', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  149. { title: '款数', dataIndex: 'productTotalCategory', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  150. { title: '数量', dataIndex: 'productTotalQty', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  151. // { title: '成本', dataIndex: 'productTotalCost', width: '7%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  152. { title: '审核时间', dataIndex: 'auditTime', width: '13%', align: 'center', customRender: function (text) { return text || '--' } }
  153. ]
  154. if (this.$hasPermissions('M_ShowAllCost')) {
  155. arr.splice(6, 0, { title: '成本', dataIndex: 'productTotalCost', width: '7%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  156. }
  157. return arr
  158. }
  159. },
  160. methods: {
  161. // 选择调往对象
  162. custChange (v, row) {
  163. if (row && row.customerSn) {
  164. this.queryParam.customerSnCurrent = row.customerSn
  165. this.queryParam.customerNameCurrent = undefined
  166. } else {
  167. this.queryParam.customerNameCurrent = v
  168. this.queryParam.customerSnCurrent = undefined
  169. }
  170. },
  171. // 合计
  172. getCount (params) {
  173. reportStoreCallOutListTotal(params).then(res => {
  174. if (res.status == 200) {
  175. this.totalData = res.data
  176. } else {
  177. this.totalData = null
  178. }
  179. })
  180. },
  181. // 创建时间 change
  182. dateChange (date) {
  183. this.queryParam.time = date
  184. this.queryParam.beginDate = date[0] || ''
  185. this.queryParam.endDate = date[1] || ''
  186. },
  187. // 出库时间
  188. outWareDateChange (date) {
  189. this.queryParam.outWarehouseBeginDate = date[0]
  190. this.queryParam.outWarehouseEndDate = date[1]
  191. },
  192. // 查询
  193. handleSearch () {
  194. this.$refs.ruleForm.validate(valid => {
  195. if (valid) {
  196. this.$refs.table.refresh(true)
  197. } else {
  198. return false
  199. }
  200. })
  201. },
  202. // 重置
  203. resetSearchForm () {
  204. this.$refs.rangeDate.resetDate()
  205. this.queryParam.time = []
  206. this.queryParam.beginDate = ''
  207. this.queryParam.endDate = ''
  208. this.$refs.outWareRangeDate.resetDate('')
  209. this.outWareTime = []
  210. this.queryParam.outWarehouseBeginDate = ''
  211. this.queryParam.outWarehouseEndDate = ''
  212. this.$refs.custList.resetForm()
  213. this.queryParam.customerSnCurrent = undefined
  214. this.queryParam.customerNameCurrent = undefined
  215. this.queryParam.storeCallOutNo = ''
  216. this.queryParam.callOutType = undefined
  217. this.$refs.ruleForm.resetFields()
  218. this.totalData = null
  219. this.$refs.table.clearTable()
  220. },
  221. // 导出
  222. handleExport () {
  223. const _this = this
  224. this.$refs.ruleForm.validate(valid => {
  225. if (valid) {
  226. const params = _this.queryParam
  227. params.showCost = this.$hasPermissions('M_ShowAllCost') ? '1' : '0'
  228. _this.exportLoading = true
  229. _this.spinning = true
  230. reportStoreCallOutExport(params).then(res => {
  231. downloadExcel(res, '店内调出报表')
  232. _this.exportLoading = false
  233. _this.spinning = false
  234. })
  235. } else {
  236. console.log('error submit!!')
  237. return false
  238. }
  239. })
  240. },
  241. // 调拨类型
  242. getStoreCallOutTypeAllList () {
  243. storeCallOutTypeAllList().then(res => {
  244. if (res.status == 200) {
  245. this.storeCallOutTypeList = res.data
  246. } else {
  247. this.storeCallOutTypeList = []
  248. }
  249. })
  250. },
  251. // 初始化
  252. pageInit () {
  253. this.getStoreCallOutTypeAllList()
  254. }
  255. },
  256. mounted () {
  257. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  258. this.pageInit()
  259. this.resetSearchForm()
  260. }
  261. },
  262. activated () {
  263. // 如果是新页签打开,则重置当前页面
  264. if (this.$store.state.app.isNewTab) {
  265. this.pageInit()
  266. this.resetSearchForm()
  267. }
  268. },
  269. beforeRouteEnter (to, from, next) {
  270. next(vm => {})
  271. }
  272. }
  273. </script>