list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <template>
  2. <a-card size="small" :bordered="false" class="sendStorageReportList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form-model
  6. id="sendStorageReportList-form"
  7. ref="ruleForm"
  8. :model="queryParam"
  9. :rules="rules"
  10. :labelCol="labelCol"
  11. :wrapperCol="wrapperCol"
  12. @keyup.enter.native="handleSearch" >
  13. <a-row :gutter="15">
  14. <a-col :md="6" :sm="24">
  15. <a-form-model-item label="连锁店" prop="targetName">
  16. <a-select
  17. placeholder="请选择连锁店"
  18. id="sendStorageReportList-targetName"
  19. allowClear
  20. v-model="queryParam.targetName"
  21. :showSearch="true"
  22. option-filter-prop="children"
  23. :filter-option="filterOption">
  24. <a-select-option v-for="item in allocateTypeList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  25. </a-select>
  26. </a-form-model-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-model-item label="日期">
  30. <rangeDate ref="rangeDate" @change="dateChange" />
  31. </a-form-model-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-model-item label="产品编码">
  35. <a-input id="sendStorageReportList-code" v-model.trim="queryParam.code" allowClear placeholder="请输入产品编码"/>
  36. </a-form-model-item>
  37. </a-col>
  38. <template v-if="advanced">
  39. <a-col :md="6" :sm="24">
  40. <a-form-model-item label="产品名称">
  41. <a-input id="sendStorageReportList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  42. </a-form-model-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24">
  45. <a-form-model-item label="产品品牌">
  46. <a-select
  47. placeholder="请选择产品品牌"
  48. id="sendStorageReportList-productBrandSn"
  49. allowClear
  50. v-model="queryParam.productBrandSn"
  51. :showSearch="true"
  52. option-filter-prop="children"
  53. :filter-option="filterOption">
  54. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  55. </a-select>
  56. </a-form-model-item>
  57. </a-col>
  58. <a-col :md="6" :sm="24">
  59. <a-form-model-item label="产品分类">
  60. <a-cascader
  61. @change="changeProductType"
  62. change-on-select
  63. v-model="productType"
  64. expand-trigger="hover"
  65. :options="productTypeList"
  66. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  67. id="sendStorageReportList-productType"
  68. placeholder="请选择产品分类"
  69. allowClear />
  70. </a-form-model-item>
  71. </a-col>
  72. </template>
  73. <a-col :md="6" :sm="24">
  74. <a-button type="primary" @click="handleSearch" :disabled="disabled" id="sendStorageReportList-refresh">查询</a-button>
  75. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="sendStorageReportList-reset">重置</a-button>
  76. <a @click="advanced=!advanced" style="margin-left: 8px">
  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. <s-table
  86. class="sTable"
  87. ref="table"
  88. size="small"
  89. :rowKey="(record) => record.id"
  90. :columns="columns"
  91. :data="loadData"
  92. :scroll="{ x: 2390 }"
  93. bordered>
  94. <template slot="footer" slot-scope="currentPageData">
  95. <span>
  96. 合计: 期初数量:{{ totalData.beginQty || 0 }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;期初金额:{{ totalData.beginAmount || 0 }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 收入数量:{{ totalData.putQty || 0 }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 收入金额:{{ totalData.putAmount || 0 }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 发出数量:{{ totalData.outQty || 0 }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 发出金额:{{ totalData.outAmount || 0 }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 结算数量:{{ totalData.endQty || 0 }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 结算金额:{{ totalData.endAmount || 0 }}
  97. </span>
  98. </template>
  99. </s-table>
  100. </a-card>
  101. </template>
  102. <script>
  103. import { STable, VSelect } from '@/components'
  104. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  105. import { dealerProductTypeList } from '@/api/dealerProductType'
  106. import rangeDate from '@/views/common/rangeDate.vue'
  107. import { linkageReportPageList, linkageReportPageTotal } from '@/api/reportData.js'
  108. export default {
  109. components: { STable, VSelect, rangeDate },
  110. data () {
  111. return {
  112. advanced: false, // 高级搜索 展开/关闭
  113. tableHeight: 0,
  114. queryParam: { // 查询条件
  115. beginDate: '',
  116. endDate: '',
  117. targetName: undefined,
  118. code: '', // 产品编码
  119. name: '', // 产品名称
  120. origCode: '', // 原厂编码
  121. productBrandSn: undefined, // 产品品牌
  122. productTypeSn1: '', // 产品一级分类
  123. productTypeSn2: '', // 产品二级分类
  124. productTypeSn3: '' // 产品三级分类
  125. },
  126. labelCol: { span: 8 },
  127. wrapperCol: { span: 16 },
  128. rules: {
  129. 'targetName': [{ required: true, message: '请选择连锁店', trigger: 'change' }],
  130. 'date': [{ required: true, message: '请选择日期', trigger: 'change' }]
  131. },
  132. disabled: false, // 查询、重置按钮是否可操作
  133. exportLoading: false,
  134. columns: [
  135. { title: '序号',
  136. dataIndex: 'no',
  137. width: 80,
  138. align: 'center'
  139. // fixed: 'left'
  140. },
  141. { title: '产品编码',
  142. dataIndex: 'code',
  143. width: 220,
  144. align: 'center',
  145. customRender: function (value, row, index) {
  146. value = row.productEntity && row.productEntity.code ? row.productEntity.code : '--'
  147. const obj = { children: value, attrs: {} }
  148. if (value == '合计') { obj.attrs.colSpan = 0 }
  149. obj.children = row.productEntity && row.productEntity.code ? row.productEntity.code : '--'
  150. return obj
  151. }
  152. },
  153. { title: '产品名称',
  154. dataIndex: 'name',
  155. width: 220,
  156. align: 'center',
  157. customRender: function (value, row, index) {
  158. value = value || '--'
  159. const obj = { children: value, attrs: {} }
  160. if (value == '合计') { obj.attrs.colSpan = 0 }
  161. obj.children = row.productEntity && row.productEntity.name ? row.productEntity.name : '--'
  162. return obj
  163. },
  164. ellipsis: true
  165. },
  166. { title: '品牌',
  167. dataIndex: 'productBrandName',
  168. align: 'center',
  169. width: 200,
  170. customRender: function (value, row, index) {
  171. value = value || '--'
  172. const obj = { children: value, attrs: {} }
  173. if (value == '合计') { obj.attrs.colSpan = 0 }
  174. obj.children = row.productEntity && row.productEntity.productBrandName ? row.productEntity.productBrandName : '--'
  175. return obj
  176. }
  177. },
  178. { title: '三级分类',
  179. dataIndex: 'productTypeName3',
  180. width: 150,
  181. align: 'center',
  182. customRender: function (value, row, index) {
  183. value = value || '--'
  184. const obj = { children: value, attrs: {} }
  185. if (value == '合计') { obj.attrs.colSpan = 0 }
  186. obj.children = row.productEntity && row.productEntity.productTypeName3 ? row.productEntity.productTypeName3 : '--'
  187. return obj
  188. }
  189. },
  190. { title: '原厂编码',
  191. dataIndex: 'origCode',
  192. width: 220,
  193. align: 'center',
  194. customRender: function (value, row, index) {
  195. value = value || '--'
  196. const obj = { children: value, attrs: {} }
  197. if (value == '合计') { obj.attrs.colSpan = 0 }
  198. obj.children = row.productEntity && row.productEntity.origCode ? row.productEntity.origCode : '--'
  199. return obj
  200. }
  201. },
  202. { title: '单位',
  203. dataIndex: 'unit',
  204. width: 100,
  205. align: 'center',
  206. customRender: function (value, row, index) {
  207. value = value || '--'
  208. const obj = { children: value, attrs: {} }
  209. if (value == '合计') { obj.attrs.colSpan = 0 }
  210. obj.children = row.productEntity && row.productEntity.unit ? row.productEntity.unit : '--'
  211. return obj
  212. }
  213. },
  214. { title: '期初数量', dataIndex: 'beginQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  215. { title: '期初单价(¥)', dataIndex: 'beginPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  216. { title: '期初金额(¥)', dataIndex: 'beginAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  217. { title: '收入数量', dataIndex: 'putQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  218. { title: '收入单价(¥)', dataIndex: 'putPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  219. { title: '收入金额(¥)', dataIndex: 'putAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  220. { title: '发出数量', dataIndex: 'outQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  221. { title: '发出单价(¥)', dataIndex: 'outPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  222. { title: '发出金额(¥)', dataIndex: 'outAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  223. { title: '结存数量', dataIndex: 'endQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  224. { title: '结存单价(¥)', dataIndex: 'endPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  225. { title: '结存金额(¥)', dataIndex: 'endAmount', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } }
  226. ],
  227. // 加载数据方法 必须为 Promise 对象
  228. loadData: async parameter => {
  229. if (this.queryParam.beginDate) {
  230. this.disabled = true
  231. const params = {
  232. beginDate: this.queryParam.beginDate,
  233. endDate: this.queryParam.endDate,
  234. targetName: this.queryParam.targetName,
  235. productEntity: {
  236. code: this.queryParam.code, // 产品编码
  237. name: this.queryParam.name, // 产品名称
  238. origCode: this.queryParam.origCode, // 原厂编码
  239. productBrandSn: this.queryParam.productBrandSn, // 产品品牌
  240. productTypeSn1: this.queryParam.productTypeSn1, // 产品一级分类
  241. productTypeSn2: this.queryParam.productTypeSn2, // 产品二级分类
  242. productTypeSn3: this.queryParam.productTypeSn3 // 产品三级分类
  243. }
  244. }
  245. return linkageReportPageList(Object.assign(parameter, params)).then(res => {
  246. const data = res.data
  247. const no = (data.pageNo - 1) * data.pageSize
  248. for (var i = 0; i < data.list.length; i++) {
  249. data.list[i].no = no + i + 1
  250. }
  251. this.disabled = false
  252. return data
  253. })
  254. } else {
  255. return new Promise(function (resolve, reject) {
  256. const data = {
  257. pageNo: 1,
  258. pageSize: 10,
  259. list: [],
  260. count: 10
  261. }
  262. resolve(data)
  263. })
  264. }
  265. },
  266. productType: [],
  267. productBrandList: [], // 品牌下拉数据
  268. productTypeList: [], // 分类下拉数据
  269. allocateTypeList: [], // 调拨类型
  270. totalData: {} // 合计
  271. }
  272. },
  273. methods: {
  274. // 时间 change
  275. dateChange (date) {
  276. this.queryParam.beginDate = date[0]
  277. this.queryParam.endDate = date[1]
  278. },
  279. // 查询
  280. handleSearch () {
  281. if (!this.queryParam.beginDate) {
  282. return this.$message.error('请先选择日期')
  283. }
  284. this.$refs.table.refresh(true)
  285. this.getTotal()
  286. // this.$refs.ruleForm.validate(valid => {
  287. // if (valid) {
  288. // if (!this.queryParam.beginDate) {
  289. // return this.$message.error('请先选择日期')
  290. // }
  291. // this.$refs.table.refresh(true)
  292. // this.getTotal()
  293. // } else {
  294. // console.log('error submit!!')
  295. // return false
  296. // }
  297. // })
  298. },
  299. // 查询总计
  300. getTotal () {
  301. const params = {
  302. beginDate: this.queryParam.beginDate,
  303. endDate: this.queryParam.endDate,
  304. targetName: this.queryParam.targetName,
  305. productEntity: {
  306. code: this.queryParam.code, // 产品编码
  307. name: this.queryParam.name, // 产品名称
  308. origCode: this.queryParam.origCode, // 原厂编码
  309. productBrandSn: this.queryParam.productBrandSn, // 产品品牌
  310. productTypeSn1: this.queryParam.productTypeSn1, // 产品一级分类
  311. productTypeSn2: this.queryParam.productTypeSn2, // 产品二级分类
  312. productTypeSn3: this.queryParam.productTypeSn3 // 产品三级分类
  313. }
  314. }
  315. linkageReportPageTotal(params).then(res => {
  316. if (res.status == 200 && res.data) {
  317. this.totalData = res.data
  318. } else {
  319. this.totalData = {}
  320. }
  321. })
  322. },
  323. // 重置
  324. resetSearchForm () {
  325. this.queryParam.targetName = undefined
  326. this.queryParam.code = ''
  327. this.queryParam.name = ''
  328. this.queryParam.origCode = ''
  329. this.queryParam.productBrandSn = undefined
  330. this.queryParam.productTypeSn1 = ''
  331. this.queryParam.productTypeSn2 = ''
  332. this.queryParam.productTypeSn3 = ''
  333. this.productType = []
  334. this.$refs.table.refresh(true)
  335. },
  336. // 产品分类 change
  337. changeProductType (val, opt) {
  338. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  339. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  340. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  341. },
  342. // 产品品牌 列表
  343. getProductBrand () {
  344. dealerProductBrandQuery({}).then(res => {
  345. if (res.status == 200) {
  346. this.productBrandList = res.data
  347. } else {
  348. this.productBrandList = []
  349. }
  350. })
  351. },
  352. // 产品分类 列表
  353. getProductType () {
  354. dealerProductTypeList({}).then(res => {
  355. if (res.status == 200) {
  356. this.productTypeList = res.data
  357. } else {
  358. this.productTypeList = []
  359. }
  360. })
  361. },
  362. filterOption (input, option) {
  363. return (
  364. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  365. )
  366. }
  367. },
  368. beforeRouteEnter (to, from, next) {
  369. next(vm => {
  370. vm.getProductBrand()
  371. vm.getProductType()
  372. })
  373. }
  374. }
  375. </script>