list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="productNotOnline-wrap searchBoxNormal">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="searchForm">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="定价时间">
  10. <rangeDate ref="rangeDate" id="productNotOnline-rangeDate" :value="time" @change="dateChange" />
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="产品编码/原厂编码">
  15. <a-input id="productNotOnline-queryWord" v-model.trim="queryParam.queryWord" allowClear placeholder="请输入产品编码/原厂编码"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-item label="产品名称">
  20. <a-input id="productNotOnline-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="定价状态">
  26. <v-select code="PRICING_STATUS" id="productNotOnline-pricingState" v-model="queryParam.pricingState" allowClear placeholder="请选择定价状态"></v-select>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="产品状态">
  31. <v-select code="PRODUCT_STATUS" id="productNotOnline-state" v-model="queryParam.state" allowClear placeholder="请选择产品状态"></v-select>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="品牌">
  36. <ProductBrand id="productNotOnline-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :md="6" :sm="24">
  40. <a-form-item label="产品分类">
  41. <ProductType id="productNotOnline-productType" placeholder="请选择产品分类" @change="changeProductType" v-model="productType"></ProductType>
  42. </a-form-item>
  43. </a-col>
  44. </template>
  45. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  46. <a-button type="primary" @click="searchForm" :disabled="disabled" id="productNotOnline-refresh">查询</a-button>
  47. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productNotOnline-reset">重置</a-button>
  48. <a-button
  49. style="margin-left: 5px"
  50. type="primary"
  51. class="button-warning"
  52. @click="handleExport"
  53. :disabled="disabled"
  54. v-if="$hasPermissions('M_productOnlineExport')"
  55. id="productNotOnline-export">导出</a-button>
  56. <a @click="advanced=!advanced" style="margin-left: 5px" id="productNotOnline-advanced">
  57. {{ advanced ? '收起' : '展开' }}
  58. <a-icon :type="advanced ? 'up' : 'down'"/>
  59. </a>
  60. </a-col>
  61. </a-row>
  62. </a-form>
  63. </div>
  64. </a-card>
  65. <a-card size="small" :bordered="false">
  66. <a-spin :spinning="spinning" tip="Loading...">
  67. <!-- 操作按钮 -->
  68. <div class="table-operator" style="text-align:right;">
  69. <a-checkbox v-model="zeroQtyFlag" id="productNotOnline-zeroQtyFlag" @change="handleChangeQty">仅显示有库存</a-checkbox>
  70. </div>
  71. <!-- 列表 -->
  72. <s-table
  73. class="sTable fixPagination"
  74. ref="table"
  75. :style="{ height: tableHeight+70+'px' }"
  76. size="small"
  77. :rowKey="(record) => record.no"
  78. rowKeyName="no"
  79. :columns="columns"
  80. :data="loadData"
  81. :scroll="{y: tableHeight }"
  82. :defaultLoadData="false"
  83. bordered>
  84. <!-- 产品分类 -->
  85. <template slot="productType" slot-scope="text, record">
  86. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  87. <span v-else>--</span>
  88. </template>
  89. </s-table>
  90. </a-spin>
  91. </a-card>
  92. </div>
  93. </template>
  94. <script>
  95. import { commonMixin } from '@/utils/mixin'
  96. import { exportExcel } from '@/libs/JGPrint.js'
  97. // 组件
  98. import rangeDate from '@/views/common/rangeDate.vue'
  99. import { STable, VSelect } from '@/components'
  100. import ProductType from '@/views/common/productType.js'
  101. import ProductBrand from '@/views/common/productBrand.js'
  102. // 接口
  103. import { queryOnlinePage, excelOnlineList } from '@/api/product'
  104. export default {
  105. name: 'ProductNotOnlineList',
  106. mixins: [commonMixin],
  107. components: { STable, VSelect, rangeDate, ProductBrand, ProductType },
  108. data () {
  109. return {
  110. spinning: false,
  111. advanced: true, // 高级搜索 展开/关闭
  112. disabled: false, // 查询、重置按钮是否可操作
  113. tableHeight: 0, // 表格高度
  114. time: [], // 定价时间
  115. // 查询条件
  116. queryParam: {
  117. name: '', // 产品名称
  118. queryWord: '', // 产品编码/原厂编码
  119. productBrandSn: undefined, // 产品品牌
  120. productTypeSn1: '', // 产品一级分类
  121. productTypeSn2: '', // 产品二级分类
  122. productTypeSn3: '', // 产品三级分类
  123. pricingState: undefined, // 定价状态
  124. pricingTimeBegin: undefined, // 定价开始时间
  125. pricingTimeEnd: undefined, // 定价结束时间
  126. state: undefined, // 产品状态
  127. stockFlag: undefined// 仅显示有库存 1是 0否
  128. },
  129. zeroQtyFlag: false, // 仅显示有库存 true是 false否
  130. productType: [], // 产品分类
  131. // 加载数据方法 必须为 Promise 对象
  132. loadData: parameter => {
  133. this.disabled = true
  134. this.spinning = true
  135. // 获取表格数据 有分页
  136. return queryOnlinePage(Object.assign(parameter, this.queryParam)).then(res => {
  137. let data
  138. if (res.status == 200) {
  139. data = res.data
  140. // 计算表格序号
  141. const no = (data.pageNo - 1) * data.pageSize
  142. for (var i = 0; i < data.list.length; i++) {
  143. data.list[i].no = no + i + 1
  144. }
  145. this.disabled = false
  146. }
  147. this.spinning = false
  148. return data
  149. })
  150. }
  151. }
  152. },
  153. computed: {
  154. columns () {
  155. const _this = this
  156. const arr = [
  157. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  158. { title: '创建时间', dataIndex: 'createDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  159. { title: '产品名称', dataIndex: 'name', align: 'left', width: '12%', customRender: function (text) { return text || '--' }, ellipsis: true },
  160. { title: '产品编码', dataIndex: 'code', width: '7%', align: 'left', customRender: function (text) { return text || '--' } },
  161. { title: '原厂编码', dataIndex: 'origCode', width: '7%', align: 'left', customRender: function (text) { return text || '--' } },
  162. { title: '品牌', dataIndex: 'productBrandName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  163. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '10%', align: 'left' },
  164. { title: '仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  165. { title: '可用库存', dataIndex: 'currentStockQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  166. { title: '第一次入库时间', dataIndex: 'skCreateDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  167. { title: '产品状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  168. { title: '定价状态', dataIndex: 'pricingStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '定价时间', dataIndex: 'pricingTime', width: '6%', align: 'center', customRender: function (text) { return text || '--' } }
  170. ]
  171. if (this.$hasPermissions('M_productNotOnlineList_costPrice')) {
  172. arr.push({ title: '最新成本', dataIndex: 'lastStockCost', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  173. }
  174. if (this.$hasPermissions('M_productNotOnlineList_provincePrice')) {
  175. arr.push({ title: '省级价', dataIndex: 'provincePrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  176. }
  177. if (this.$hasPermissions('M_productNotOnlineList_cityPrice')) {
  178. arr.push({ title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  179. }
  180. if (this.$hasPermissions('M_productNotOnlineList_specialPrice')) {
  181. arr.push({ title: '特约价', dataIndex: 'specialPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  182. }
  183. if (this.$hasPermissions('M_productNotOnlineList_terminalPrice')) {
  184. arr.push({ title: '终端价', dataIndex: 'terminalPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  185. }
  186. if (this.$hasPermissions('M_productNotOnlineList_carOwnersPrice')) {
  187. arr.push({ title: '车主价', dataIndex: 'carOwnersPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  188. }
  189. return arr
  190. }
  191. },
  192. methods: {
  193. // 定价时间 change
  194. dateChange (date) {
  195. this.queryParam.pricingTimeBegin = date[0]
  196. this.queryParam.pricingTimeEnd = date[1]
  197. },
  198. // 仅显示有库存
  199. handleChangeQty (e) {
  200. this.zeroQtyFlag = e.target.checked
  201. this.queryParam.stockFlag = e.target.checked ? '1' : undefined
  202. this.$refs.table.refresh(true)
  203. },
  204. // 重置
  205. resetSearchForm () {
  206. this.queryParam.name = ''
  207. this.queryParam.queryWord = ''
  208. this.queryParam.productBrandSn = undefined
  209. this.queryParam.productTypeSn1 = ''
  210. this.queryParam.productTypeSn2 = ''
  211. this.queryParam.productTypeSn3 = ''
  212. this.queryParam.pricingState = undefined
  213. this.queryParam.stockFlag = undefined
  214. this.zeroQtyFlag = false
  215. this.queryParam.pricingTimeBegin = undefined
  216. this.queryParam.pricingTimeEnd = undefined
  217. this.queryParam.state = undefined
  218. this.time = []
  219. this.$refs.rangeDate.resetDate(this.time)
  220. this.productType = []
  221. this.$refs.table.clearSelected() // 清空表格选中项
  222. this.$refs.table.refresh(true)
  223. },
  224. // 查询
  225. searchForm () {
  226. this.$refs.table.clearSelected() // 清空表格选中项
  227. this.$refs.table.refresh(true)
  228. },
  229. // 导出
  230. handleExport () {
  231. const _this = this
  232. _this.$store.state.app.curActionPermission = 'M_productOnlineExport'
  233. const params = this.queryParam
  234. this.spinning = true
  235. exportExcel(excelOnlineList, params, '产品状态信息导出', function () {
  236. _this.spinning = false
  237. _this.$store.state.app.curActionPermission = ''
  238. })
  239. },
  240. // 产品分类 change
  241. changeProductType (val, opt) {
  242. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  243. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  244. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  245. },
  246. // 初始化
  247. pageInit () {
  248. const _this = this
  249. this.$nextTick(() => { // 页面渲染完成后的回调
  250. _this.setTableH()
  251. })
  252. },
  253. // 计算表格高度
  254. setTableH () {
  255. const tableSearchH = this.$refs.tableSearch.offsetHeight
  256. this.tableHeight = window.innerHeight - tableSearchH - 226
  257. }
  258. },
  259. watch: {
  260. // 展开/关闭 监听表格高度变化
  261. advanced (newValue, oldValue) {
  262. const _this = this
  263. this.$nextTick(() => { // 页面渲染完成后的回调
  264. _this.setTableH()
  265. })
  266. },
  267. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  268. this.setTableH()
  269. }
  270. },
  271. mounted () {
  272. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  273. this.pageInit()
  274. this.resetSearchForm()
  275. }
  276. },
  277. activated () {
  278. // 如果是新页签打开,则重置当前页面
  279. if (this.$store.state.app.isNewTab) {
  280. this.pageInit()
  281. this.resetSearchForm()
  282. }
  283. // 仅刷新列表,不重置页面
  284. if (this.$store.state.app.updateList) {
  285. this.pageInit()
  286. this.$refs.table.refresh()
  287. }
  288. },
  289. beforeRouteEnter (to, from, next) {
  290. next(vm => {})
  291. }
  292. }
  293. </script>