detailList.vue 13 KB

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