list.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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-button
  49. style="margin-left: 5px"
  50. type="primary"
  51. class="button-warning"
  52. @click="handleExport"
  53. :disabled="disabled"
  54. id="productInfoList-export">导出</a-button>
  55. <a @click="advanced=!advanced" style="margin-left: 5px">
  56. {{ advanced ? '收起' : '展开' }}
  57. <a-icon :type="advanced ? 'up' : 'down'"/>
  58. </a>
  59. </a-col>
  60. </a-row>
  61. </a-form>
  62. </div>
  63. <!-- 操作按钮 -->
  64. <div class="table-operator">
  65. <a-button
  66. id="productPricingList-batchAudit"
  67. type="primary"
  68. class="button-warning"
  69. :loading="spinning"
  70. @click="handleBatchAudit"
  71. style="margin: 0 15px 0 0;">批量审核</a-button>
  72. <span>已选{{ rowSelectionInfo&&rowSelectionInfo.selectedRowKeys?rowSelectionInfo.selectedRowKeys.length:0 }}项</span>
  73. <a-button style="margin: 0 0 0 15px;" id="productPricingList-add" type="primary" class="button-error">定价导入</a-button>
  74. </div>
  75. <!-- 列表 -->
  76. <s-table
  77. class="sTable fixPagination"
  78. ref="table"
  79. :style="{ height: tableHeight+84.5+'px' }"
  80. size="small"
  81. :row-selection="{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: record.pricingState=='WAIT_PRICING_AUDIT' } })}"
  82. @rowSelection="rowSelectionFun"
  83. :rowKey="(record) => record.id"
  84. :columns="columns"
  85. :data="loadData"
  86. :scroll="{y: tableHeight }"
  87. :defaultLoadData="false"
  88. bordered>
  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="sterminaldsdPrice" slot-scope="text, record">
  96. <div v-if="record.supplierProductList">
  97. <p v-for="(item, index) in record.supplierProductList" :key="index" style="margin: 0;">
  98. <span>{{ (item.cost || item.cost==0) ? item.cost.toFixed(2):'--' }}</span>元 -
  99. <span>{{ (item.supplierName||'') }}</span>;
  100. </p>
  101. </div>
  102. <span v-else>--</span>
  103. </template>
  104. <!-- 操作 -->
  105. <template slot="action" slot-scope="text, record">
  106. <a-button
  107. size="small"
  108. type="link"
  109. v-if="record.pricingState=='WAIT_PRICING_AUDIT' && $hasPermissions('B_productPricing_audit')"
  110. class="button-warning"
  111. @click="handleAudit(record)"
  112. id="productPricingList-audit-btn">审核</a-button>
  113. <a-button
  114. size="small"
  115. type="link"
  116. v-if="$hasPermissions('B_productPricing_edit')"
  117. class="button-info"
  118. @click="handleEdit(record)"
  119. id="productPricingList-edit-btn">编辑</a-button>
  120. <span v-if="!(record.pricingState=='WAIT_PRICING_AUDIT' && $hasPermissions('B_productPricing_audit')) && !$hasPermissions('B_productPricing_edit')">--</span>
  121. </template>
  122. </s-table>
  123. </a-spin>
  124. <!-- 编辑价格 -->
  125. <product-pricing-edit-modal :openModal="openModal" :itemSn="itemSn" @close="closeModal" @ok="$refs.table.refresh()" />
  126. <!-- 审核价格 -->
  127. <product-pricing-audit-modal :openModal="openAuditModal" :itemSn="itemSn" @close="closeAuditModal" @ok="$refs.table.refresh()" />
  128. </a-card>
  129. </template>
  130. <script>
  131. import { commonMixin } from '@/utils/mixin'
  132. import { STable, VSelect } from '@/components'
  133. import { exportExcel } from '@/libs/JGPrint.js'
  134. import productPricingEditModal from './editModal.vue'
  135. import productPricingAuditModal from './auditModal.vue'
  136. import { productBrandQuery } from '@/api/productBrand'
  137. import { productTypeQuery } from '@/api/productType'
  138. import { productPricingList } from '@/api/product'
  139. import ProductBrand from '@/views/common/productBrand.js'
  140. export default {
  141. name: 'ProductPricingList',
  142. mixins: [commonMixin],
  143. components: { STable, VSelect, productPricingEditModal, productPricingAuditModal, ProductBrand },
  144. data () {
  145. return {
  146. spinning: false,
  147. advanced: true, // 高级搜索 展开/关闭
  148. tableHeight: 0,
  149. queryParam: { // 查询条件
  150. name: '', // 产品名称
  151. queryWord: '', // 产品编码/原厂编码
  152. productBrandSn: undefined, // 产品品牌
  153. productTypeSn1: '', // 产品一级分类
  154. productTypeSn2: '', // 产品二级分类
  155. productTypeSn3: '', // 产品三级分类
  156. pricingState: undefined // 定价状态
  157. },
  158. productType: [],
  159. disabled: false, // 查询、重置按钮是否可操作
  160. // 加载数据方法 必须为 Promise 对象
  161. loadData: parameter => {
  162. this.disabled = true
  163. this.spinning = true
  164. return productPricingList(Object.assign(parameter, this.queryParam)).then(res => {
  165. let data
  166. if (res.status == 200) {
  167. data = res.data
  168. const no = (data.pageNo - 1) * data.pageSize
  169. for (var i = 0; i < data.list.length; i++) {
  170. data.list[i].no = no + i + 1
  171. }
  172. this.total = data.count || 0
  173. this.disabled = false
  174. }
  175. this.spinning = false
  176. return data
  177. })
  178. },
  179. total: 0, // 合计
  180. openModal: false, // 编辑 弹框
  181. openAuditModal: false, // 审核 弹框
  182. itemSn: '', // 当前产品sn
  183. productBrandList: [], // 品牌下拉数据
  184. productTypeList: [], // 分类下拉数据
  185. rowSelectionInfo: null
  186. }
  187. },
  188. computed: {
  189. columns () {
  190. const arr = [
  191. { title: '序号', dataIndex: 'no', width: '3%', align: 'center' },
  192. { title: '创建时间', dataIndex: 'createDate', width: '8%', align: 'center', customRender: function (text) { return text || '--' } },
  193. { title: '产品名称', dataIndex: 'name', align: 'left', width: '13%', customRender: function (text) { return text || '--' }, ellipsis: true },
  194. { title: '产品编码', dataIndex: 'code', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  195. { title: '原厂编码', dataIndex: 'origCode', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  196. { title: '品牌', dataIndex: 'productBrandName', width: '5%', align: 'center', customRender: function (text) { return text || '--' } },
  197. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: '7%', align: 'center' },
  198. { title: '产品状态', dataIndex: 'stateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  199. { title: '定价状态', dataIndex: 'pricingStateDictValue', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  200. // { title: '成本价', scopedSlots: { customRender: 'sterminaldsdPrice' }, width: '7%', align: 'center' },
  201. // { title: '省级价', dataIndex: 'provincePrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  202. // { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  203. { title: '特约价', dataIndex: 'specialPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  204. { title: '终端价', dataIndex: 'terminalPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  205. { title: '车主价', dataIndex: 'carOwnersPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  206. { title: '操作', scopedSlots: { customRender: 'action' }, width: '8%', align: 'center' }
  207. ]
  208. if (this.$hasPermissions('B_isShowCost')) {
  209. arr.splice(9, 0, { title: '成本价', scopedSlots: { customRender: 'sterminaldsdPrice' }, width: '7%', align: 'center' })
  210. if (this.$hasPermissions('B_isShowProvincePrice')) {
  211. arr.splice(10, 0, { title: '省级价', dataIndex: 'provincePrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  212. if (this.$hasPermissions('B_isShowCityPrice')) {
  213. arr.splice(11, 0, { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  214. }
  215. } else {
  216. if (this.$hasPermissions('B_isShowCityPrice')) {
  217. arr.splice(10, 0, { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  218. }
  219. }
  220. } else {
  221. if (this.$hasPermissions('B_isShowProvincePrice')) {
  222. arr.splice(9, 0, { title: '省级价', dataIndex: 'provincePrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  223. if (this.$hasPermissions('B_isShowCityPrice')) {
  224. arr.splice(10, 0, { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  225. }
  226. } else {
  227. if (this.$hasPermissions('B_isShowCityPrice')) {
  228. arr.splice(9, 0, { title: '市级价', dataIndex: 'cityPrice', width: '5%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  229. }
  230. }
  231. }
  232. return arr
  233. }
  234. },
  235. methods: {
  236. // 表格选中项
  237. rowSelectionFun (obj) {
  238. this.rowSelectionInfo = obj || null
  239. },
  240. // 重置
  241. resetSearchForm () {
  242. this.queryParam.name = ''
  243. this.queryParam.queryWord = ''
  244. this.queryParam.productBrandSn = undefined
  245. this.queryParam.productTypeSn1 = ''
  246. this.queryParam.productTypeSn2 = ''
  247. this.queryParam.productTypeSn3 = ''
  248. this.queryParam.pricingState = undefined
  249. this.productType = []
  250. this.$refs.table.refresh(true)
  251. },
  252. // 审核
  253. handleAudit (row) {
  254. this.itemSn = row.productSn
  255. this.openAuditModal = true
  256. },
  257. // 批量审核
  258. handleBatchAudit () {
  259. const _this = this
  260. if (!_this.rowSelectionInfo || (_this.rowSelectionInfo && _this.rowSelectionInfo.selectedRowKeys.length < 1)) {
  261. _this.$message.warning('请先选择产品!')
  262. return
  263. }
  264. const obj = []
  265. _this.rowSelectionInfo && _this.rowSelectionInfo.selectedRows.map(item => {
  266. obj.push(item.productSn)
  267. })
  268. this.$confirm({
  269. title: '提示',
  270. content: '确认要审核通过吗?',
  271. centered: true,
  272. onOk () {
  273. _this.spinning = true
  274. productBatchAudit(obj).then(res => {
  275. if (res.status == 200) {
  276. _this.$refs.table.clearSelected() // 清空表格选中项
  277. _this.$message.success(res.message)
  278. _this.$refs.table.refresh()
  279. _this.spinning = false
  280. } else {
  281. _this.spinning = false
  282. }
  283. })
  284. }
  285. })
  286. },
  287. // 导出
  288. handleExport () {
  289. const _this = this
  290. const params = this.queryParam
  291. this.spinning = true
  292. exportExcel(productExport, params, '产品价格导出', function () {
  293. _this.spinning = false
  294. })
  295. },
  296. // 编辑
  297. handleEdit (row) {
  298. this.itemSn = row.productSn
  299. this.openModal = true
  300. },
  301. // 关闭弹框
  302. closeModal () {
  303. this.itemSn = ''
  304. this.openModal = false
  305. },
  306. // 关闭审核弹框
  307. closeAuditModal () {
  308. this.itemSn = ''
  309. this.openAuditModal = false
  310. },
  311. // 产品分类 change
  312. changeProductType (val, opt) {
  313. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  314. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  315. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  316. },
  317. // 产品品牌 列表
  318. getProductBrand () {
  319. productBrandQuery({}).then(res => {
  320. if (res.status == 200) {
  321. this.productBrandList = res.data
  322. } else {
  323. this.productBrandList = []
  324. }
  325. })
  326. },
  327. // 产品分类 列表
  328. getProductType () {
  329. productTypeQuery({}).then(res => {
  330. if (res.status == 200) {
  331. this.productTypeList = res.data
  332. } else {
  333. this.productTypeList = []
  334. }
  335. })
  336. },
  337. pageInit () {
  338. const _this = this
  339. this.$nextTick(() => { // 页面渲染完成后的回调
  340. _this.setTableH()
  341. })
  342. this.getProductBrand()
  343. this.getProductType()
  344. },
  345. setTableH () {
  346. const tableSearchH = this.$refs.tableSearch.offsetHeight
  347. this.tableHeight = window.innerHeight - tableSearchH - 235
  348. }
  349. },
  350. watch: {
  351. advanced (newValue, oldValue) {
  352. const _this = this
  353. this.$nextTick(() => { // 页面渲染完成后的回调
  354. _this.setTableH()
  355. })
  356. },
  357. '$store.state.app.winHeight' (newValue, oldValue) { // 窗口变更时,需同时更改表格高度
  358. this.setTableH()
  359. }
  360. },
  361. mounted () {
  362. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  363. this.pageInit()
  364. this.resetSearchForm()
  365. }
  366. },
  367. activated () {
  368. // 如果是新页签打开,则重置当前页面
  369. if (this.$store.state.app.isNewTab) {
  370. this.pageInit()
  371. this.resetSearchForm()
  372. }
  373. // 仅刷新列表,不重置页面
  374. if (this.$store.state.app.updateList) {
  375. this.pageInit()
  376. this.$refs.table.refresh()
  377. }
  378. },
  379. beforeRouteEnter (to, from, next) {
  380. next(vm => {})
  381. }
  382. }
  383. </script>