list.vue 9.4 KB

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