list.vue 14 KB

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