list.vue 18 KB

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