list.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <a-card size="small" :bordered="false" class="productPricingList-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="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-select>
  22. </a-form-item>
  23. </a-col>
  24. <template v-if="advanced">
  25. <a-col :md="6" :sm="24">
  26. <a-form-item label="产品分类">
  27. <a-cascader
  28. @change="changeProductType"
  29. expand-trigger="hover"
  30. change-on-select
  31. :options="productTypeList"
  32. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  33. id="productPricingList-productType"
  34. placeholder="请选择产品分类"
  35. allowClear
  36. v-model="productType" />
  37. </a-form-item>
  38. </a-col>
  39. <a-col :md="6" :sm="24">
  40. <a-form-item label="定价状态">
  41. <v-select code="PRICING_STATUS" id="productPricingList-pricingState" v-model="queryParam.pricingState" 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="$refs.table.refresh(true)" :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 @click="advanced=!advanced" style="margin-left: 5px">
  49. {{ advanced ? '收起' : '展开' }}
  50. <a-icon :type="advanced ? 'up' : 'down'"/>
  51. </a>
  52. </a-col>
  53. </a-row>
  54. </a-form>
  55. </div>
  56. <!-- 列表 -->
  57. <s-table
  58. class="sTable fixPagination"
  59. ref="table"
  60. :style="{ height: tableHeight+84.5+'px' }"
  61. size="small"
  62. :rowKey="(record) => record.id"
  63. :columns="columns"
  64. :data="loadData"
  65. :scroll="{y: tableHeight }"
  66. :defaultLoadData="false"
  67. bordered>
  68. <!-- 产品分类 -->
  69. <template slot="productType" slot-scope="text, record">
  70. <span v-if="record.productTypeName2 || record.productTypeName3">{{ record.productTypeName2 }} {{ record.productTypeName3 ? '>' : '' }} {{ record.productTypeName3 }}</span>
  71. <span v-else>--</span>
  72. </template>
  73. <!-- 成本价 -->
  74. <template slot="sterminaldsdPrice" slot-scope="text, record">
  75. <div v-if="record.supplierProductList">
  76. <p v-for="(item, index) in record.supplierProductList" :key="index" style="margin: 0;">
  77. <span>{{ (item.cost || item.cost==0) ? item.cost.toFixed(2):'--' }}</span>元 -
  78. <span>{{ (item.supplierName||'') }}</span>;
  79. </p>
  80. </div>
  81. <span v-else>--</span>
  82. </template>
  83. <!-- 操作 -->
  84. <template slot="action" slot-scope="text, record">
  85. <a-button
  86. size="small"
  87. type="link"
  88. v-if="record.pricingState=='WAIT_PRICING_AUDIT' && $hasPermissions('B_productPricing_audit')"
  89. class="button-warning"
  90. @click="handleAudit(record)"
  91. id="productPricingList-audit-btn">审核</a-button>
  92. <a-button
  93. size="small"
  94. type="link"
  95. v-if="$hasPermissions('B_productPricing_edit')"
  96. class="button-info"
  97. @click="handleEdit(record)"
  98. id="productPricingList-edit-btn">编辑</a-button>
  99. <span v-if="!(record.pricingState=='WAIT_PRICING_AUDIT' && $hasPermissions('B_productPricing_audit')) && !$hasPermissions('B_productPricing_edit')">--</span>
  100. </template>
  101. </s-table>
  102. </a-spin>
  103. <!-- 编辑价格 -->
  104. <product-pricing-edit-modal :openModal="openModal" :itemSn="itemSn" @close="closeModal" @ok="$refs.table.refresh()" />
  105. <!-- 审核价格 -->
  106. <product-pricing-audit-modal :openModal="openAuditModal" :itemSn="itemSn" @close="closeAuditModal" @ok="$refs.table.refresh()" />
  107. </a-card>
  108. </template>
  109. <script>
  110. import { STable, VSelect } from '@/components'
  111. import productPricingEditModal from './editModal.vue'
  112. import productPricingAuditModal from './auditModal.vue'
  113. import { productBrandQuery } from '@/api/productBrand'
  114. import { productTypeQuery } from '@/api/productType'
  115. import { productPricingList } from '@/api/product'
  116. import ProductBrand from '@/views/common/productBrand.js'
  117. export default {
  118. components: { STable, VSelect, productPricingEditModal, productPricingAuditModal, ProductBrand },
  119. data () {
  120. return {
  121. spinning: false,
  122. advanced: true, // 高级搜索 展开/关闭
  123. tableHeight: 0,
  124. queryParam: { // 查询条件
  125. name: '', // 产品名称
  126. queryWord: '', // 产品编码/原厂编码
  127. productBrandSn: undefined, // 产品品牌
  128. productTypeSn1: '', // 产品一级分类
  129. productTypeSn2: '', // 产品二级分类
  130. productTypeSn3: '', // 产品三级分类
  131. pricingState: undefined // 定价状态
  132. },
  133. productType: [],
  134. disabled: false, // 查询、重置按钮是否可操作
  135. // 加载数据方法 必须为 Promise 对象
  136. loadData: parameter => {
  137. this.disabled = true
  138. this.spinning = true
  139. return productPricingList(Object.assign(parameter, this.queryParam)).then(res => {
  140. let data
  141. if (res.status == 200) {
  142. data = res.data
  143. const no = (data.pageNo - 1) * data.pageSize
  144. for (var i = 0; i < data.list.length; i++) {
  145. data.list[i].no = no + i + 1
  146. }
  147. this.total = data.count || 0
  148. this.disabled = false
  149. }
  150. this.spinning = false
  151. return data
  152. })
  153. },
  154. total: 0, // 合计
  155. openModal: false, // 编辑 弹框
  156. openAuditModal: false, // 审核 弹框
  157. itemSn: '', // 当前产品sn
  158. productBrandList: [], // 品牌下拉数据
  159. productTypeList: [] // 分类下拉数据
  160. }
  161. },
  162. computed: {
  163. columns () {
  164. const arr = [
  165. { title: '序号', dataIndex: 'no', width: '3%', align: 'center' },
  166. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  167. { title: '产品名称', dataIndex: 'name', align: 'left', width: '13%', customRender: function (text) { return text || '--' }, ellipsis: true },
  168. { title: '产品编码', dataIndex: 'code', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  169. { title: '原厂编码', dataIndex: 'origCode', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  170. { title: '品牌', dataIndex: 'productBrandName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  171. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '7%', align: 'center' },
  172. { title: '产品状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  173. { title: '定价状态', dataIndex: 'pricingStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  174. // { title: '成本价', scopedSlots: { customRender: 'sterminaldsdPrice' }, width: '7%', align: 'center' },
  175. // { title: '省级价', dataIndex: 'provincePrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  176. // { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  177. { title: '特约价', dataIndex: 'specialPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  178. { title: '终端价', dataIndex: 'terminalPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  179. { title: '车主价', dataIndex: 'carOwnersPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  180. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  181. ]
  182. if (this.$hasPermissions('B_isShowCost')) {
  183. arr.splice(9, 0, { title: '成本价', scopedSlots: { customRender: 'sterminaldsdPrice' }, width: '7%', align: 'center' })
  184. if (this.$hasPermissions('B_isShowProvincePrice')) {
  185. arr.splice(10, 0, { title: '省级价', dataIndex: 'provincePrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  186. if (this.$hasPermissions('B_isShowCityPrice')) {
  187. arr.splice(11, 0, { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  188. }
  189. } else {
  190. if (this.$hasPermissions('B_isShowCityPrice')) {
  191. arr.splice(10, 0, { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  192. }
  193. }
  194. } else {
  195. if (this.$hasPermissions('B_isShowProvincePrice')) {
  196. arr.splice(9, 0, { title: '省级价', dataIndex: 'provincePrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  197. if (this.$hasPermissions('B_isShowCityPrice')) {
  198. arr.splice(10, 0, { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  199. }
  200. } else {
  201. if (this.$hasPermissions('B_isShowCityPrice')) {
  202. arr.splice(9, 0, { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  203. }
  204. }
  205. }
  206. return arr
  207. }
  208. },
  209. methods: {
  210. // 重置
  211. resetSearchForm () {
  212. this.queryParam.name = ''
  213. this.queryParam.queryWord = ''
  214. this.queryParam.productBrandSn = undefined
  215. this.queryParam.productTypeSn1 = ''
  216. this.queryParam.productTypeSn2 = ''
  217. this.queryParam.productTypeSn3 = ''
  218. this.queryParam.pricingState = undefined
  219. this.productType = []
  220. this.$refs.table.refresh(true)
  221. },
  222. // 审核
  223. handleAudit (row) {
  224. this.itemSn = row.productSn
  225. this.openAuditModal = true
  226. },
  227. // 编辑
  228. handleEdit (row) {
  229. this.itemSn = row.productSn
  230. this.openModal = true
  231. },
  232. // 关闭弹框
  233. closeModal () {
  234. this.itemSn = ''
  235. this.openModal = false
  236. },
  237. // 关闭审核弹框
  238. closeAuditModal () {
  239. this.itemSn = ''
  240. this.openAuditModal = false
  241. },
  242. // 产品分类 change
  243. changeProductType (val, opt) {
  244. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  245. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  246. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  247. },
  248. // 产品品牌 列表
  249. getProductBrand () {
  250. productBrandQuery({}).then(res => {
  251. if (res.status == 200) {
  252. this.productBrandList = res.data
  253. } else {
  254. this.productBrandList = []
  255. }
  256. })
  257. },
  258. // 产品分类 列表
  259. getProductType () {
  260. productTypeQuery({}).then(res => {
  261. if (res.status == 200) {
  262. this.productTypeList = res.data
  263. } else {
  264. this.productTypeList = []
  265. }
  266. })
  267. },
  268. pageInit () {
  269. const _this = this
  270. this.$nextTick(() => { // 页面渲染完成后的回调
  271. _this.setTableH()
  272. })
  273. this.getProductBrand()
  274. this.getProductType()
  275. },
  276. setTableH () {
  277. const tableSearchH = this.$refs.tableSearch.offsetHeight
  278. this.tableHeight = window.innerHeight - tableSearchH - 195
  279. }
  280. },
  281. watch: {
  282. advanced (newValue, oldValue) {
  283. const _this = this
  284. this.$nextTick(() => { // 页面渲染完成后的回调
  285. _this.setTableH()
  286. })
  287. },
  288. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  289. this.setTableH()
  290. }
  291. },
  292. mounted () {
  293. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  294. this.pageInit()
  295. this.resetSearchForm()
  296. }
  297. },
  298. activated () {
  299. // 如果是新页签打开,则重置当前页面
  300. if (this.$store.state.app.isNewTab) {
  301. this.pageInit()
  302. this.resetSearchForm()
  303. }
  304. // 仅刷新列表,不重置页面
  305. if (this.$store.state.app.updateList) {
  306. this.pageInit()
  307. this.$refs.table.refresh()
  308. }
  309. },
  310. beforeRouteEnter (to, from, next) {
  311. next(vm => {})
  312. }
  313. }
  314. </script>