list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. <template>
  2. <a-card size="small" :bordered="false" class="sendStorageReportList-wrap">
  3. <!-- 搜索条件 -->
  4. <a-spin :spinning="spinning" tip="Loading...">
  5. <div class="table-page-search-wrapper">
  6. <a-form-model
  7. id="sendStorageReportList-form"
  8. ref="ruleForm"
  9. class="form-model-con"
  10. layout="inline"
  11. :model="queryParam"
  12. :rules="rules"
  13. :labelCol="labelCol"
  14. :wrapperCol="wrapperCol"
  15. @keyup.enter.native="handleSearch" >
  16. <a-row :gutter="15">
  17. <a-col :md="6" :sm="24">
  18. <a-form-model-item label="连锁店" prop="tenantId">
  19. <a-select
  20. placeholder="请选择连锁店"
  21. id="sendStorageReportList-tenantId"
  22. allowClear
  23. v-model="queryParam.tenantId"
  24. :showSearch="true"
  25. option-filter-prop="children"
  26. :filter-option="filterOption">
  27. <a-select-option v-for="item in linkageGroupData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
  28. </a-select>
  29. </a-form-model-item>
  30. </a-col>
  31. <a-col :md="6" :sm="24">
  32. <a-form-model-item label="日期" prop="auditDate">
  33. <a-month-picker v-model="queryParam.auditDate" :allowClear="false" @change="onChange" :defaultValue="moment()" style="width: 100%;" />
  34. </a-form-model-item>
  35. </a-col>
  36. <a-col :md="6" :sm="24">
  37. <a-form-model-item label="产品编码">
  38. <a-input id="sendStorageReportList-code" v-model.trim="queryParam.productEntity.code" allowClear placeholder="请输入产品编码"/>
  39. </a-form-model-item>
  40. </a-col>
  41. <template v-if="advanced">
  42. <a-col :md="6" :sm="24">
  43. <a-form-model-item label="产品名称">
  44. <a-input id="sendStorageReportList-name" v-model.trim="queryParam.productEntity.name" allowClear placeholder="请输入产品名称"/>
  45. </a-form-model-item>
  46. </a-col>
  47. <a-col :md="6" :sm="24">
  48. <a-form-model-item label="产品品牌">
  49. <a-select
  50. placeholder="请选择产品品牌"
  51. id="sendStorageReportList-productBrandSn"
  52. allowClear
  53. v-model="queryParam.productEntity.productBrandSn"
  54. :showSearch="true"
  55. option-filter-prop="children"
  56. :filter-option="filterOption">
  57. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  58. </a-select>
  59. </a-form-model-item>
  60. </a-col>
  61. <a-col :md="6" :sm="24">
  62. <a-form-model-item label="产品分类">
  63. <a-cascader
  64. @change="changeProductType"
  65. change-on-select
  66. v-model="productType"
  67. expand-trigger="hover"
  68. :options="productTypeList"
  69. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  70. id="sendStorageReportList-productType"
  71. placeholder="请选择产品分类"
  72. allowClear />
  73. </a-form-model-item>
  74. </a-col>
  75. </template>
  76. <a-col :md="6" :sm="24">
  77. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="sendStorageReportList-refresh">查询</a-button>
  78. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="sendStorageReportList-reset">重置</a-button>
  79. <a @click="advanced=!advanced" style="margin-left: 8px">
  80. {{ advanced ? '收起' : '展开' }}
  81. <a-icon :type="advanced ? 'up' : 'down'"/>
  82. </a>
  83. </a-col>
  84. </a-row>
  85. </a-form-model>
  86. </div>
  87. <!-- 列表 -->
  88. <s-table
  89. class="sTable"
  90. ref="table"
  91. size="small"
  92. :defaultLoadData="false"
  93. :rowKey="(record) => record.id"
  94. :columns="columns"
  95. :data="loadData"
  96. :scroll="{ x: 1830 }"
  97. bordered>
  98. <template slot="footer" slot-scope="currentPageData">
  99. <span>
  100. 合计: 期初数量:{{ (totalData && (totalData.beginQty || totalData.beginQty==0)) ? totalData.beginQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  101. 期初金额:{{ (totalData && (totalData.beginAmount || totalData.beginAmount==0)) ? totalData.beginAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  102. 收入数量:{{ (totalData && (totalData.putQty || totalData.putQty==0)) ? totalData.putQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  103. 收入金额:{{ (totalData && (totalData.putAmount || totalData.putAmount==0)) ? totalData.putAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  104. 发出数量:{{ (totalData && (totalData.outQty || totalData.outQty==0)) ? totalData.outQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  105. 发出金额:{{ (totalData && (totalData.outAmount || totalData.outAmount==0)) ? totalData.outAmount : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  106. 结算数量:{{ (totalData && (totalData.endQty || totalData.endQty==0)) ? totalData.endQty : '--' }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  107. 结算金额:{{ (totalData && (totalData.endAmount || totalData.endAmount==0)) ? totalData.endAmount : '--' }}
  108. </span>
  109. </template>
  110. </s-table>
  111. </a-spin>
  112. </a-card>
  113. </template>
  114. <script>
  115. import moment from 'moment'
  116. import { STable, VSelect } from '@/components'
  117. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  118. import { dealerProductTypeList } from '@/api/dealerProductType'
  119. import { linkageReportPageList, linkageReportPageTotal, linkageGroupList } from '@/api/reportData'
  120. export default {
  121. components: { STable, VSelect },
  122. data () {
  123. return {
  124. moment,
  125. spinning: false,
  126. advanced: true, // 高级搜索 展开/关闭
  127. tableHeight: 0,
  128. queryParam: { // 查询条件
  129. auditDate: moment().format('YYYY-MM'),
  130. tenantId: undefined,
  131. productEntity: {
  132. code: '', // 产品编码
  133. name: '', // 产品名称
  134. productBrandSn: undefined, // 产品品牌
  135. productTypeSn1: '', // 产品一级分类
  136. productTypeSn2: '', // 产品二级分类
  137. productTypeSn3: '' // 产品三级分类
  138. }
  139. },
  140. labelCol: { span: 8 },
  141. wrapperCol: { span: 16 },
  142. rules: {
  143. 'tenantId': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  144. 'auditDate': [{ required: true, message: '请选择日期', trigger: 'change' }]
  145. },
  146. disabled: false, // 查询、重置按钮是否可操作
  147. exportLoading: false,
  148. columns: [
  149. { title: '产品编码', dataIndex: 'productCode', width: 120, align: 'left', customRender: function (text) { return text || '--' }, sorter: true },
  150. { title: '产品名称', dataIndex: 'productEntity.name', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  151. { title: '品牌', dataIndex: 'productEntity.productBrandName', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  152. { title: '三级分类', dataIndex: 'productEntity.productTypeName3', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  153. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: 130, align: 'left', customRender: function (text) { return text || '--' } },
  154. { title: '单位', dataIndex: 'productEntity.unit', width: 50, align: 'center', customRender: function (text) { return text || '--' } },
  155. { title: '期初数量', dataIndex: 'beginQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  156. { title: '期初单价(¥)', dataIndex: 'beginPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  157. { title: '期初金额(¥)', dataIndex: 'beginAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  158. { title: '收入数量', dataIndex: 'putQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  159. { title: '收入单价(¥)', dataIndex: 'putPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  160. { title: '收入金额(¥)', dataIndex: 'putAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  161. { title: '发出数量', dataIndex: 'outQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  162. { title: '发出单价(¥)', dataIndex: 'outPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  163. { title: '发出金额(¥)', dataIndex: 'outAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  164. { title: '结存数量', dataIndex: 'endQty', width: 80, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  165. { title: '结存单价(¥)', dataIndex: 'endPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  166. { title: '结存金额(¥)', dataIndex: 'endAmount', width: 100, align: 'center', sorter: true, customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  167. ],
  168. // 加载数据方法 必须为 Promise 对象
  169. loadData: parameter => {
  170. this.disabled = true
  171. const params = Object.assign(parameter, this.queryParam)
  172. this.spinning = true
  173. if (this.queryParam.auditDate && this.queryParam.tenantId) {
  174. params.auditDate = this.queryParam.auditDate + '-01'
  175. return linkageReportPageList(params).then(res => {
  176. // 总计
  177. this.getCount(params)
  178. const data = res.data
  179. const no = (data.pageNo - 1) * data.pageSize
  180. for (var i = 0; i < data.list.length; i++) {
  181. data.list[i].no = no + i + 1
  182. }
  183. this.disabled = false
  184. this.spinning = false
  185. return data
  186. })
  187. } else {
  188. const _this = this
  189. return new Promise(function (resolve, reject) {
  190. const data = {
  191. pageNo: 1,
  192. pageSize: 10,
  193. list: [],
  194. count: 0
  195. }
  196. _this.disabled = false
  197. _this.spinning = false
  198. _this.$message.info('请选择连锁店和日期')
  199. resolve(data)
  200. })
  201. }
  202. },
  203. productType: [],
  204. linkageGroupData: [],
  205. productBrandList: [], // 品牌下拉数据
  206. productTypeList: [], // 分类下拉数据
  207. totalData: null // 合计
  208. }
  209. },
  210. methods: {
  211. // 月份 change
  212. onChange (date, dateString) {
  213. this.queryParam.auditDate = dateString || null
  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. getCount (params) {
  228. linkageReportPageTotal(params).then(res => {
  229. if (res.status == 200 && res.data) {
  230. this.totalData = res.data
  231. } else {
  232. this.totalData = null
  233. }
  234. })
  235. },
  236. // 重置
  237. resetSearchForm () {
  238. this.queryParam.tenantId = undefined
  239. this.queryParam.auditDate = moment().format('YYYY-MM')
  240. this.queryParam.productEntity.code = ''
  241. this.queryParam.productEntity.name = ''
  242. this.queryParam.productEntity.productBrandSn = undefined
  243. this.queryParam.productEntity.productTypeSn1 = ''
  244. this.queryParam.productEntity.productTypeSn2 = ''
  245. this.queryParam.productEntity.productTypeSn3 = ''
  246. this.productType = []
  247. this.$refs.ruleForm.resetFields()
  248. this.totalData = null
  249. this.$refs.table.clearTable()
  250. },
  251. // 产品分类 change
  252. changeProductType (val, opt) {
  253. this.queryParam.productEntity.productTypeSn1 = val[0] ? val[0] : ''
  254. this.queryParam.productEntity.productTypeSn2 = val[1] ? val[1] : ''
  255. this.queryParam.productEntity.productTypeSn3 = val[2] ? val[2] : ''
  256. },
  257. // 产品品牌 列表
  258. getProductBrand () {
  259. dealerProductBrandQuery({}).then(res => {
  260. if (res.status == 200) {
  261. this.productBrandList = res.data
  262. } else {
  263. this.productBrandList = []
  264. }
  265. })
  266. },
  267. // 产品分类 列表
  268. getProductType () {
  269. dealerProductTypeList({}).then(res => {
  270. if (res.status == 200) {
  271. this.productTypeList = res.data
  272. } else {
  273. this.productTypeList = []
  274. }
  275. })
  276. },
  277. filterOption (input, option) {
  278. return (
  279. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  280. )
  281. },
  282. // 连锁店
  283. getLinkageGroup () {
  284. linkageGroupList({}).then(res => {
  285. if (res.status == 200) {
  286. const data = res.data || []
  287. if (data.length > 0) {
  288. this.linkageGroupData = data
  289. } else {
  290. this.linkageGroupData = []
  291. }
  292. } else {
  293. this.linkageGroupData = []
  294. }
  295. })
  296. },
  297. pageInit () {
  298. this.getLinkageGroup()
  299. this.getProductBrand()
  300. this.getProductType()
  301. }
  302. },
  303. mounted () {
  304. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  305. this.pageInit()
  306. this.resetSearchForm()
  307. }
  308. },
  309. activated () {
  310. // 如果是新页签打开,则重置当前页面
  311. if (this.$store.state.app.isNewTab) {
  312. this.pageInit()
  313. this.resetSearchForm()
  314. }
  315. },
  316. beforeRouteEnter (to, from, next) {
  317. next(vm => {})
  318. }
  319. }
  320. </script>