list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <a-card size="small" :bordered="false" class="productPricingList-wrap">
  3. <!-- 搜索条件 -->
  4. <div class="table-page-search-wrapper">
  5. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  6. <a-row :gutter="15">
  7. <a-col :md="6" :sm="24">
  8. <a-form-item label="产品名称">
  9. <a-input id="productPricingList-productName" v-model.trim="queryParam.productName" allowClear placeholder="请输入产品名称"/>
  10. </a-form-item>
  11. </a-col>
  12. <a-col :md="6" :sm="24">
  13. <a-form-item label="产品编码/原厂编码">
  14. <a-input id="productPricingList-productCode" v-model.trim="queryParam.productCode" allowClear placeholder="请输入产品编码"/>
  15. </a-form-item>
  16. </a-col>
  17. <a-col :md="6" :sm="24">
  18. <a-form-item label="品牌">
  19. <a-select
  20. placeholder="请选择"
  21. id="productPricingList-productBrandSn"
  22. allowClear
  23. v-model="queryParam.productBrandSn"
  24. :showSearch="true"
  25. option-filter-prop="children"
  26. :filter-option="filterOption">
  27. <a-select-option v-for="item in productBrandList" :key="item.productBrandSn" :value="item.productBrandSn">{{ item.productBrandName }}</a-select-option>
  28. </a-select>
  29. </a-form-item>
  30. </a-col>
  31. <template v-if="advanced">
  32. <a-col :md="6" :sm="24">
  33. <a-form-item label="产品分类">
  34. <a-cascader
  35. @change="changeProductType"
  36. change-on-select
  37. :options="productTypeList"
  38. :fieldNames="{ label: 'productTypeName', value: 'id', children: 'children' }"
  39. id="productPricingList-productType"
  40. placeholder="请选择产品分类"
  41. allowClear />
  42. </a-form-item>
  43. </a-col>
  44. <a-col :md="6" :sm="24">
  45. <a-form-item label="定价状态">
  46. <v-select code="ENABLED_FLAG" id="productPricingList-enabledFlag" v-model="queryParam.enabledFlag" allowClear placeholder="请选择定价状态"></v-select>
  47. </a-form-item>
  48. </a-col>
  49. </template>
  50. <a-col :md="6" :sm="24">
  51. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="productPricingList-refresh">查询</a-button>
  52. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="productPricingList-reset">重置</a-button>
  53. <a @click="advanced=!advanced" style="margin-left: 8px">
  54. {{ advanced ? '收起' : '展开' }}
  55. <a-icon :type="advanced ? 'up' : 'down'"/>
  56. </a>
  57. </a-col>
  58. </a-row>
  59. </a-form>
  60. </div>
  61. <!-- 总计 -->
  62. <a-alert type="info" showIcon style="margin-bottom:15px">
  63. <div slot="message">合计:<strong>300</strong>条</div>
  64. </a-alert>
  65. <!-- 列表 -->
  66. <s-table
  67. class="sTable"
  68. ref="table"
  69. size="default"
  70. :rowKey="(record) => record.id"
  71. :columns="columns"
  72. :data="loadData"
  73. :scroll="{ x: 2010 }"
  74. bordered>
  75. <!-- 产品分类 -->
  76. <template slot="productType" slot-scope="text, record">
  77. <a-tooltip placement="top">
  78. <template slot="title">
  79. <span>{{ record.productTypeName }}</span>
  80. </template>
  81. {{ record.productTypeName3 }}
  82. </a-tooltip>
  83. </template>
  84. <!-- 产品状态 -->
  85. <template slot="status" slot-scope="text, record">
  86. <a-tag :color="record.status==1?'green':'red'" >{{ record.status==1? '待提交': '待单据审核' }}</a-tag>
  87. </template>
  88. <!-- 定价状态 -->
  89. <template slot="sstatus" slot-scope="text, record">
  90. <a-tag :color="record.status==1?'green':'red'" >{{ record.status==1? '待提交': '待单据审核' }}</a-tag>
  91. </template>
  92. <!-- 操作 -->
  93. <template slot="action" slot-scope="text, record">
  94. <a-button size="small" type="link" @click="handleAudit(record)" id="productPricingList-audit-btn">审核</a-button>
  95. <a-divider type="vertical" style="margin: 0;" />
  96. <a-button size="small" type="link" @click="handleEdit(record)" id="productPricingList-edit-btn">编辑</a-button>
  97. </template>
  98. </s-table>
  99. <!-- 编辑价格 -->
  100. <product-pricing-edit-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  101. <!-- 审核价格 -->
  102. <product-pricing-audit-modal :openModal="openAuditModal" :itemId="itemId" @close="closeAuditModal" />
  103. </a-card>
  104. </template>
  105. <script>
  106. // import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  107. // import { dealerProductTypeQuery } from '@/api/dealerProductType'
  108. import { STable, VSelect } from '@/components'
  109. import productPricingEditModal from './editModal.vue'
  110. import productPricingAuditModal from './auditModal.vue'
  111. export default {
  112. components: { STable, VSelect, productPricingEditModal, productPricingAuditModal },
  113. data () {
  114. return {
  115. advanced: false, // 高级搜索 展开/关闭
  116. queryParam: { // 查询条件
  117. productName: '', // 产品名称
  118. productCode: '', // 产品编码/原厂编码
  119. productBrandSn: undefined, // 品牌
  120. productTypeSn1: '', // 产品一级分类
  121. productTypeSn2: '', // 产品二级分类
  122. productTypeSn3: '', // 产品三级分类
  123. enabledFlag: undefined // 定价状态
  124. },
  125. disabled: false, // 查询、重置按钮是否可操作
  126. columns: [
  127. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  128. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  129. { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  130. { title: '产品编码', dataIndex: 'productCode', width: 140, align: 'center' },
  131. { title: '原厂编码', dataIndex: 'origCode', width: 140, align: 'center', customRender: function (text) { return text || '--' } },
  132. { title: '品牌', dataIndex: 'productBrandName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  133. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 200, align: 'center' },
  134. { title: '产品状态', scopedSlots: { customRender: 'status' }, width: 120, align: 'center' },
  135. { title: '定价状态', scopedSlots: { customRender: 'sstatus' }, width: 120, align: 'center' },
  136. { title: '成本价', dataIndex: 'sterminaldsdPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  137. { title: '省级价', dataIndex: 'sdterminaldsdPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  138. { title: '市级价', dataIndex: 'fterminaldsdPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  139. { title: '特约价', dataIndex: 'gterminaldsdPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  140. { title: '终端价', dataIndex: 'hterminaldsdPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  141. { title: '车主价', dataIndex: 'terminaldsdPrice', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  142. { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
  143. ],
  144. // 加载数据方法 必须为 Promise 对象
  145. loadData: parameter => {
  146. this.disabled = true
  147. // return dealerProductList(Object.assign(parameter, this.queryParam)).then(res => {
  148. // const data = res.data
  149. // const no = (data.pageNo - 1) * data.pageSize
  150. // for (var i = 0; i < data.list.length; i++) {
  151. // data.list[i].no = no + i + 1
  152. // const productTypeName1 = data.list[i].productTypeName1 ? data.list[i].productTypeName1 : ''
  153. // const productTypeName2 = data.list[i].productTypeName2 ? ' > ' + data.list[i].productTypeName2 : ''
  154. // const productTypeName3 = data.list[i].productTypeName3 ? ' > ' + data.list[i].productTypeName3 : ''
  155. // data.list[i].productTypeName = productTypeName1 + productTypeName2 + productTypeName3
  156. // }
  157. // this.disabled = false
  158. // return data
  159. // })
  160. const _this = this
  161. return new Promise(function (resolve, reject) {
  162. const data = {
  163. pageNo: 1,
  164. pageSize: 10,
  165. list: [
  166. { id: '1', productNum: 'jgqp11111111111', productName: '产品1', productPic: ['https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg', 'https://qn.antdv.com/vue.png'], productOldNum: 'jgqp111123545', productBrand: '箭冠品牌', productType: '产品分类1', inventoryNum: '5', inventoryMoney: '122' }
  167. ]
  168. }
  169. const no = (data.pageNo - 1) * data.pageSize
  170. for (var i = 0; i < data.list.length; i++) {
  171. data.list[i].no = no + i + 1
  172. }
  173. _this.disabled = false
  174. resolve(data)
  175. })
  176. },
  177. openModal: false, // 编辑 弹框
  178. openAuditModal: false, // 审核 弹框
  179. itemId: '', // 当前产品id
  180. productBrandList: [], // 品牌下拉数据
  181. productTypeList: [] // 分类下拉数据
  182. }
  183. },
  184. methods: {
  185. // 重置
  186. resetSearchForm () {
  187. this.queryParam.productCode = ''
  188. this.queryParam.productName = ''
  189. this.queryParam.productBrandSn = undefined
  190. this.queryParam.productTypeSn1 = ''
  191. this.queryParam.productTypeSn2 = ''
  192. this.queryParam.productTypeSn3 = ''
  193. this.queryParam.enabledFlag = undefined
  194. this.$refs.table.refresh(true)
  195. },
  196. // 审核
  197. handleAudit (row) {
  198. this.itemId = row.id
  199. this.openAuditModal = true
  200. },
  201. filterOption (input, option) {
  202. return (
  203. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  204. )
  205. },
  206. // 编辑
  207. handleEdit (row) {
  208. this.itemId = row.id
  209. this.openModal = true
  210. },
  211. // 关闭弹框
  212. closeModal () {
  213. this.itemId = ''
  214. this.openModal = false
  215. },
  216. // 关闭审核弹框
  217. closeAuditModal () {
  218. this.itemId = ''
  219. this.openAuditModal = false
  220. },
  221. // 产品分类 change
  222. changeProductType (val, opt) {
  223. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  224. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  225. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  226. },
  227. // 产品品牌 列表
  228. getProductBrand () {
  229. dealerProductBrandQuery({}).then(res => {
  230. if (res.status == 200) {
  231. this.productBrandList = res.data
  232. } else {
  233. this.productBrandList = []
  234. }
  235. })
  236. },
  237. // 产品分类 列表
  238. getProductType () {
  239. dealerProductTypeQuery({}).then(res => {
  240. if (res.status == 200) {
  241. this.productTypeList = res.data
  242. } else {
  243. this.productTypeList = []
  244. }
  245. })
  246. }
  247. },
  248. beforeRouteEnter (to, from, next) {
  249. next(vm => {
  250. vm.getProductBrand()
  251. vm.getProductType()
  252. })
  253. }
  254. }
  255. </script>