list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. <template>
  2. <div>
  3. <a-card size="small" :bordered="false" class="productPricingList-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. <a-input id="productPricingList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :md="6" :sm="24">
  14. <a-form-item label="产品编码/原厂编码">
  15. <a-input id="productPricingList-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. <ProductBrand id="productPricingList-productBrandSn" v-model="queryParam.productBrandSn"></ProductBrand>
  21. </a-form-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-model-item label="产品分类">
  26. <ProductType id="productPricingList-productType" placeholder="请选择产品分类" @change="changeProductType" v-model="productType"></ProductType>
  27. </a-form-model-item>
  28. </a-col>
  29. <a-col :md="6" :sm="24">
  30. <a-form-item label="定价时间">
  31. <rangeDate ref="rangeDate" :value="time" @change="dateChange" />
  32. </a-form-item>
  33. </a-col>
  34. <a-col :md="6" :sm="24">
  35. <a-form-item label="定价状态">
  36. <v-select code="PRICING_STATUS" id="productPricingList-pricingState" v-model="queryParam.pricingState" allowClear placeholder="请选择定价状态"></v-select>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :md="6" :sm="24">
  40. <a-form-item label="产品状态">
  41. <v-select code="PRODUCT_STATUS" id="productInfoList-state" v-model="queryParam.state" allowClear placeholder="请选择产品状态"></v-select>
  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="productPricingList-refresh">查询</a-button>
  47. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productPricingList-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="productInfoList-export">导出</a-button>
  56. <a @click="advanced=!advanced" style="margin-left: 5px">
  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="inventoryQueryList-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 rangeDate from '@/views/common/rangeDate.vue'
  97. import { STable, VSelect } from '@/components'
  98. import { exportExcel } from '@/libs/JGPrint.js'
  99. import { queryOnlinePage, excelOnlineList } from '@/api/product'
  100. import ProductType from '@/views/common/productType.js'
  101. import ProductBrand from '@/views/common/productBrand.js'
  102. export default {
  103. name: 'ProductNotOnlineList',
  104. mixins: [commonMixin],
  105. components: { STable, VSelect, rangeDate, ProductBrand, ProductType },
  106. data () {
  107. return {
  108. spinning: false,
  109. advanced: true, // 高级搜索 展开/关闭
  110. tableHeight: 0,
  111. time: [],
  112. queryParam: { // 查询条件
  113. name: '', // 产品名称
  114. queryWord: '', // 产品编码/原厂编码
  115. productBrandSn: undefined, // 产品品牌
  116. productTypeSn1: '', // 产品一级分类
  117. productTypeSn2: '', // 产品二级分类
  118. productTypeSn3: '', // 产品三级分类
  119. pricingState: undefined, // 定价状态
  120. pricingTimeBegin: undefined, // 定价时间
  121. pricingTimeEnd: undefined,
  122. state: undefined, // 产品状态
  123. stockFlag: undefined
  124. },
  125. zeroQtyFlag: false,
  126. productType: [],
  127. disabled: false, // 查询、重置按钮是否可操作
  128. // 加载数据方法 必须为 Promise 对象
  129. loadData: parameter => {
  130. this.disabled = true
  131. this.spinning = true
  132. return queryOnlinePage(Object.assign(parameter, this.queryParam)).then(res => {
  133. let data
  134. if (res.status == 200) {
  135. data = res.data
  136. const no = (data.pageNo - 1) * data.pageSize
  137. for (var i = 0; i < data.list.length; i++) {
  138. data.list[i].no = no + i + 1
  139. }
  140. this.disabled = false
  141. }
  142. this.spinning = false
  143. return data
  144. })
  145. }
  146. }
  147. },
  148. computed: {
  149. columns () {
  150. const _this = this
  151. const arr = [
  152. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  153. { title: '创建时间', dataIndex: 'createDate', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  154. { title: '产品名称', dataIndex: 'name', align: 'left', width: '12%', customRender: function (text) { return text || '--' }, ellipsis: true },
  155. { title: '产品编码', dataIndex: 'code', width: '7%', align: 'left', customRender: function (text) { return text || '--' } },
  156. { title: '原厂编码', dataIndex: 'origCode', width: '7%', align: 'left', customRender: function (text) { return text || '--' } },
  157. { title: '品牌', dataIndex: 'productBrandName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  158. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '10%', align: 'left' },
  159. { title: '仓库', dataIndex: 'warehouseName', width: '8%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  160. { title: '可用库存', dataIndex: 'currentStockQty', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  161. { title: '第一次入库时间', dataIndex: 'skCreateDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  162. { title: '产品状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  163. { title: '定价状态', dataIndex: 'pricingStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  164. { title: '定价时间', dataIndex: 'pricingTime', width: '6%', align: 'center', customRender: function (text) { return text || '--' } }
  165. ]
  166. if (this.$hasPermissions('M_productNotOnlineList_costPrice')) {
  167. arr.push({ title: '最新成本', dataIndex: 'lastStockCost', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  168. }
  169. if (this.$hasPermissions('M_productNotOnlineList_provincePrice')) {
  170. arr.push({ title: '省级价', dataIndex: 'provincePrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  171. }
  172. if (this.$hasPermissions('M_productNotOnlineList_cityPrice')) {
  173. arr.push({ title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  174. }
  175. if (this.$hasPermissions('M_productNotOnlineList_specialPrice')) {
  176. arr.push({ title: '特约价', dataIndex: 'specialPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  177. }
  178. if (this.$hasPermissions('M_productNotOnlineList_terminalPrice')) {
  179. arr.push({ title: '终端价', dataIndex: 'terminalPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  180. }
  181. if (this.$hasPermissions('M_productNotOnlineList_carOwnersPrice')) {
  182. arr.push({ title: '车主价', dataIndex: 'carOwnersPrice', width: '5%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  183. }
  184. return arr
  185. }
  186. },
  187. methods: {
  188. // 定价时间 change
  189. dateChange (date) {
  190. this.queryParam.pricingTimeBegin = date[0]
  191. this.queryParam.pricingTimeEnd = date[1]
  192. },
  193. handleChangeQty (e) {
  194. this.zeroQtyFlag = e.target.checked
  195. this.queryParam.stockFlag = e.target.checked ? '1' : undefined
  196. this.$refs.table.refresh(true)
  197. },
  198. // 重置
  199. resetSearchForm () {
  200. this.queryParam.name = ''
  201. this.queryParam.queryWord = ''
  202. this.queryParam.productBrandSn = undefined
  203. this.queryParam.productTypeSn1 = ''
  204. this.queryParam.productTypeSn2 = ''
  205. this.queryParam.productTypeSn3 = ''
  206. this.queryParam.pricingState = undefined
  207. this.queryParam.stockFlag = undefined
  208. this.zeroQtyFlag = false
  209. this.queryParam.pricingTimeBegin = undefined
  210. this.queryParam.pricingTimeEnd = undefined
  211. this.queryParam.state = undefined
  212. this.time = []
  213. this.$refs.rangeDate.resetDate(this.time)
  214. this.productType = []
  215. this.$refs.table.clearSelected() // 清空表格选中项
  216. this.$refs.table.refresh(true)
  217. },
  218. searchForm () {
  219. this.$refs.table.clearSelected() // 清空表格选中项
  220. this.$refs.table.refresh(true)
  221. },
  222. // 导出
  223. handleExport () {
  224. const _this = this
  225. _this.$store.state.app.curActionPermission = 'M_productOnlineExport'
  226. const params = this.queryParam
  227. this.spinning = true
  228. exportExcel(excelOnlineList, params, '产品状态信息导出', function () {
  229. _this.spinning = false
  230. _this.$store.state.app.curActionPermission = ''
  231. })
  232. },
  233. // 产品分类 change
  234. changeProductType (val, opt) {
  235. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  236. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  237. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  238. },
  239. pageInit () {
  240. const _this = this
  241. this.$nextTick(() => { // 页面渲染完成后的回调
  242. _this.setTableH()
  243. })
  244. },
  245. setTableH () {
  246. const tableSearchH = this.$refs.tableSearch.offsetHeight
  247. this.tableHeight = window.innerHeight - tableSearchH - 226
  248. }
  249. },
  250. watch: {
  251. advanced (newValue, oldValue) {
  252. const _this = this
  253. this.$nextTick(() => { // 页面渲染完成后的回调
  254. _this.setTableH()
  255. })
  256. },
  257. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  258. this.setTableH()
  259. }
  260. },
  261. mounted () {
  262. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  263. this.pageInit()
  264. this.resetSearchForm()
  265. }
  266. },
  267. activated () {
  268. // 如果是新页签打开,则重置当前页面
  269. if (this.$store.state.app.isNewTab) {
  270. this.pageInit()
  271. this.resetSearchForm()
  272. }
  273. // 仅刷新列表,不重置页面
  274. if (this.$store.state.app.updateList) {
  275. this.pageInit()
  276. this.$refs.table.refresh()
  277. }
  278. },
  279. beforeRouteEnter (to, from, next) {
  280. next(vm => {})
  281. }
  282. }
  283. </script>