list.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <a-card size="small" :bordered="false" class="productInfoList-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <!-- 搜索条件 -->
  5. <div ref="tableSearch" class="table-page-search-wrapper">
  6. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  7. <a-row :gutter="15">
  8. <a-col :md="6" :sm="24">
  9. <a-form-item label="产品编码">
  10. <a-input id="productInfoList-code" v-model.trim="queryParam.code" 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="productInfoList-name" v-model.trim="queryParam.name" allowClear placeholder="请输入产品名称"/>
  16. </a-form-item>
  17. </a-col>
  18. <a-col :md="6" :sm="24">
  19. <a-form-model-item :label="($route.params.onlineFalg=='1'?'上':'下')+'线时间'">
  20. <rangeDate ref="rangeDate" @change="dateChange" />
  21. </a-form-model-item>
  22. </a-col>
  23. <template v-if="advanced">
  24. <a-col :md="6" :sm="24">
  25. <a-form-item label="产品品牌">
  26. <a-select
  27. placeholder="请选择产品品牌"
  28. id="productInfoList-productBrandSn"
  29. allowClear
  30. v-model="queryParam.productBrandSn"
  31. :showSearch="true"
  32. option-filter-prop="children"
  33. :filter-option="filterOption">
  34. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  35. </a-select>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :md="6" :sm="24">
  39. <a-form-item label="产品分类">
  40. <a-cascader
  41. @change="changeProductType"
  42. change-on-select
  43. v-model="productType"
  44. expand-trigger="hover"
  45. :options="productTypeList"
  46. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  47. id="productInfoList-productType"
  48. placeholder="请选择产品分类"
  49. allowClear />
  50. </a-form-item>
  51. </a-col>
  52. <a-col :md="6" :sm="24">
  53. <a-form-item label="原厂编码">
  54. <a-input id="productInfoList-origCode" v-model.trim="queryParam.origCode" allowClear placeholder="请输入原厂编码"/>
  55. </a-form-item>
  56. </a-col>
  57. </template>
  58. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  59. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productInfoList-refresh">查询</a-button>
  60. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="productInfoList-reset">重置</a-button>
  61. <a @click="advanced=!advanced" style="margin-left: 5px">
  62. {{ advanced ? '收起' : '展开' }}
  63. <a-icon :type="advanced ? 'up' : 'down'"/>
  64. </a>
  65. </a-col>
  66. </a-row>
  67. </a-form>
  68. </div>
  69. <!-- 列表 -->
  70. <s-table
  71. class="sTable fixPagination"
  72. ref="table"
  73. :style="{ height: tableHeight+84.5+'px' }"
  74. size="small"
  75. :rowKey="(record) => record.id"
  76. :columns="columns"
  77. :data="loadData"
  78. :defaultLoadData="false"
  79. :scroll="{ x: 1090, y: tableHeight }"
  80. bordered>
  81. <!-- 上/下线时间 表头 -->
  82. <template slot="auditTimeTit">
  83. {{ $route.params.onlineFalg=='1'?'上':'下' }}线时间
  84. </template>
  85. <!-- 上/下线时间 内容 -->
  86. <template slot="auditTime" slot-scope="text, record">
  87. {{ $route.params.onlineFalg=='1'?record.onlineAuditTime:record.offlineAuditTime }}
  88. </template>
  89. <!-- 产品分类 -->
  90. <template slot="productType" slot-scope="text, record">
  91. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  92. <span v-else>--</span>
  93. </template>
  94. <!-- 操作 -->
  95. <template slot="action" slot-scope="text, record">
  96. <a-button
  97. size="small"
  98. type="link"
  99. class="button-success"
  100. @click="handleDetail(record)"
  101. id="productInfoList-detail-btn">详情</a-button>
  102. </template>
  103. </s-table>
  104. </a-spin>
  105. </a-card>
  106. </template>
  107. <script>
  108. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  109. import { dealerProductTypeList } from '@/api/dealerProductType'
  110. import { queryNewProductPage } from '@/api/product'
  111. import { STable, VSelect } from '@/components'
  112. import rangeDate from '@/views/common/rangeDate.vue'
  113. export default {
  114. components: { STable, VSelect, rangeDate },
  115. data () {
  116. return {
  117. spinning: false,
  118. advanced: true, // 高级搜索 展开/关闭
  119. tableHeight: 0,
  120. productType: [],
  121. queryParam: { // 查询条件
  122. beginDate: '',
  123. endDate: '',
  124. code: '', // 产品编码
  125. name: '', // 产品名称
  126. origCode: '', // 原厂编码
  127. sysFlag: '0',
  128. productBrandSn: undefined, // 产品品牌
  129. productTypeSn1: '', // 产品一级分类
  130. productTypeSn2: '', // 产品二级分类
  131. productTypeSn3: '', // 产品三级分类
  132. enabledFlag: undefined // 状态
  133. },
  134. disabled: false, // 查询、重置按钮是否可操作
  135. exportLoading: false, // 导出loading
  136. columns: [
  137. { title: '序号', dataIndex: 'no', width: 50, align: 'center' },
  138. { slots: { title: 'auditTimeTit' }, scopedSlots: { customRender: 'auditTime' }, width: 140, align: 'center' },
  139. { title: '产品品牌', dataIndex: 'productBrandName', width: 120, align: 'center', customRender: function (text) { return text || '--' } },
  140. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 140, align: 'center' },
  141. { title: '产品名称', dataIndex: 'name', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  142. { title: '产品编码', dataIndex: 'code', width: 180, align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '单位', dataIndex: 'unit', width: 60, align: 'center', customRender: function (text) { return text || '--' } },
  144. { title: '原厂编码', dataIndex: 'origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  145. { title: '操作', scopedSlots: { customRender: 'action' }, width: 80, align: 'center', fixed: 'right' }
  146. ],
  147. // 加载数据方法 必须为 Promise 对象
  148. loadData: parameter => {
  149. this.disabled = true
  150. this.spinning = true
  151. return queryNewProductPage(Object.assign(parameter, this.queryParam, { onlineFalg: this.$route.params.onlineFalg })).then(res => {
  152. const data = res.data
  153. const no = (data.pageNo - 1) * data.pageSize
  154. for (var i = 0; i < data.list.length; i++) {
  155. data.list[i].no = no + i + 1
  156. }
  157. this.disabled = false
  158. this.spinning = false
  159. return data
  160. })
  161. },
  162. openModal: false, // 查看详情 弹框
  163. itemId: '', // 当前产品productSn
  164. productBrandList: [], // 品牌下拉数据
  165. productTypeList: [] // 分类下拉数据
  166. }
  167. },
  168. methods: {
  169. // 创建时间 change
  170. dateChange (date) {
  171. this.queryParam.beginDate = date[0] || ''
  172. this.queryParam.endDate = date[1] || ''
  173. },
  174. // 重置
  175. resetSearchForm () {
  176. this.$refs.rangeDate.resetDate()
  177. this.queryParam.code = ''
  178. this.queryParam.name = ''
  179. this.queryParam.origCode = ''
  180. this.queryParam.productBrandSn = undefined
  181. this.queryParam.productTypeSn1 = ''
  182. this.queryParam.productTypeSn2 = ''
  183. this.queryParam.productTypeSn3 = ''
  184. this.queryParam.enabledFlag = undefined
  185. this.productType = []
  186. this.$refs.table.refresh(true)
  187. },
  188. filterOption (input, option) {
  189. return (
  190. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  191. )
  192. },
  193. // 详情
  194. handleDetail (row) {
  195. this.itemId = row.productSn
  196. this.$router.push({ name: 'viewProduct', params: { sn: row.productSn } })
  197. },
  198. // 产品分类 change
  199. changeProductType (val, opt) {
  200. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  201. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  202. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  203. },
  204. // 产品品牌 列表
  205. getProductBrand () {
  206. dealerProductBrandQuery({}).then(res => {
  207. if (res.status == 200) {
  208. this.productBrandList = res.data
  209. } else {
  210. this.productBrandList = []
  211. }
  212. })
  213. },
  214. // 产品分类 列表
  215. getProductType () {
  216. dealerProductTypeList({}).then(res => {
  217. if (res.status == 200) {
  218. this.productTypeList = res.data
  219. } else {
  220. this.productTypeList = []
  221. }
  222. })
  223. },
  224. setTableH () {
  225. const tableSearchH = this.$refs.tableSearch.offsetHeight
  226. this.tableHeight = window.innerHeight - tableSearchH - 215
  227. }
  228. },
  229. mounted () {
  230. const _this = this
  231. this.$nextTick(() => { // 页面渲染完成后的回调
  232. _this.setTableH()
  233. })
  234. },
  235. watch: {
  236. advanced (newValue, oldValue) {
  237. const _this = this
  238. setTimeout(() => {
  239. _this.setTableH()
  240. }, 400)
  241. }
  242. },
  243. beforeRouteEnter (to, from, next) {
  244. next(vm => {
  245. vm.$refs.table.refresh(true)
  246. vm.getProductBrand()
  247. vm.getProductType()
  248. })
  249. }
  250. }
  251. </script>