list.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <a-card size="small" :bordered="false" class="purchaseBaseLimitList-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="purchaseBaseLimitList-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="purchaseBaseLimitList-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="purchaseBaseLimitList-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: 'productTypeSn', children: 'children' }"
  39. id="purchaseBaseLimitList-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="purchaseBaseLimitList-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" style="margin-bottom: 10px;">
  51. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="purchaseBaseLimitList-refresh">查询</a-button>
  52. <a-button style="margin-left: 5px" @click="resetSearchForm" :disabled="disabled" id="purchaseBaseLimitList-reset">重置</a-button>
  53. <a @click="advanced=!advanced" style="margin-left: 5px">
  54. {{ advanced ? '收起' : '展开' }}
  55. <a-icon :type="advanced ? 'up' : 'down'"/>
  56. </a>
  57. </a-col>
  58. </a-row>
  59. </a-form>
  60. </div>
  61. <!-- 操作按钮 -->
  62. <div class="table-operator">
  63. <a-button id="purchaseBaseLimitList-add" type="primary" class="button-error" @click="handleAdd">新增</a-button>
  64. </div>
  65. <!-- 列表 -->
  66. <s-table
  67. class="sTable"
  68. ref="table"
  69. size="small"
  70. :rowKey="(record) => record.id"
  71. :columns="columns"
  72. :data="loadData"
  73. :scroll="{ x: 1120 }"
  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="handleDel(record)" id="purchaseBaseLimitList-del-btn">删除</a-button>
  95. </template>
  96. </s-table>
  97. <!-- 编辑 -->
  98. <purchase-base-limit-edit-modal :openModal="openModal" :itemId="itemId" @close="closeModal" />
  99. </a-card>
  100. </template>
  101. <script>
  102. // import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  103. // import { dealerProductTypeQuery } from '@/api/dealerProductType'
  104. import { STable, VSelect } from '@/components'
  105. import purchaseBaseLimitEditModal from './editModal.vue'
  106. export default {
  107. components: { STable, VSelect, purchaseBaseLimitEditModal },
  108. data () {
  109. return {
  110. advanced: true, // 高级搜索 展开/关闭
  111. queryParam: { // 查询条件
  112. productName: '', // 产品名称
  113. productCode: '', // 产品编码/原厂编码
  114. productBrandSn: undefined, // 品牌
  115. productTypeSn1: '', // 产品一级分类
  116. productTypeSn2: '', // 产品二级分类
  117. productTypeSn3: '', // 产品三级分类
  118. enabledFlag: undefined // 定价状态
  119. },
  120. disabled: false, // 查询、重置按钮是否可操作
  121. columns: [
  122. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  123. { title: '创建时间', dataIndex: 'createDate', width: 160, align: 'center' },
  124. { title: '客户级别', dataIndex: 'productdName', align: 'center', customRender: function (text) { return text || '--' } },
  125. { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true, customRender: function (text) { return text || '--' } },
  126. { title: '产品编码', dataIndex: 'productCode', width: 140, align: 'center' },
  127. { title: '产品品牌', dataIndex: 'productBrandName', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  128. { title: '产品分类', scopedSlots: { customRender: 'productType' }, width: 200, align: 'center' },
  129. { title: '操作', scopedSlots: { customRender: 'action' }, width: 150, align: 'center', fixed: 'right' }
  130. ],
  131. // 加载数据方法 必须为 Promise 对象
  132. loadData: parameter => {
  133. this.disabled = true
  134. // return dealerProductList(Object.assign(parameter, this.queryParam)).then(res => {
  135. // const data = res.data
  136. // const no = (data.pageNo - 1) * data.pageSize
  137. // for (var i = 0; i < data.list.length; i++) {
  138. // data.list[i].no = no + i + 1
  139. // const productTypeName1 = data.list[i].productTypeName1 ? data.list[i].productTypeName1 : ''
  140. // const productTypeName2 = data.list[i].productTypeName2 ? ' > ' + data.list[i].productTypeName2 : ''
  141. // const productTypeName3 = data.list[i].productTypeName3 ? ' > ' + data.list[i].productTypeName3 : ''
  142. // data.list[i].productTypeName = productTypeName1 + productTypeName2 + productTypeName3
  143. // }
  144. // this.disabled = false
  145. // return data
  146. // })
  147. const _this = this
  148. return new Promise(function (resolve, reject) {
  149. const data = {
  150. pageNo: 1,
  151. pageSize: 10,
  152. list: [
  153. { 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' }
  154. ]
  155. }
  156. const no = (data.pageNo - 1) * data.pageSize
  157. for (var i = 0; i < data.list.length; i++) {
  158. data.list[i].no = no + i + 1
  159. }
  160. _this.disabled = false
  161. resolve(data)
  162. })
  163. },
  164. openModal: false, // 编辑 弹框
  165. itemId: '', // 当前产品id
  166. productBrandList: [], // 品牌下拉数据
  167. productTypeList: [] // 分类下拉数据
  168. }
  169. },
  170. methods: {
  171. // 重置
  172. resetSearchForm () {
  173. this.queryParam.productCode = ''
  174. this.queryParam.productName = ''
  175. this.queryParam.productBrandSn = undefined
  176. this.queryParam.productTypeSn1 = ''
  177. this.queryParam.productTypeSn2 = ''
  178. this.queryParam.productTypeSn3 = ''
  179. this.queryParam.enabledFlag = undefined
  180. this.$refs.table.refresh(true)
  181. },
  182. filterOption (input, option) {
  183. return (
  184. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  185. )
  186. },
  187. // 新增
  188. handleAdd () {
  189. this.openModal = true
  190. },
  191. // 关闭弹框
  192. closeModal () {
  193. this.itemId = ''
  194. this.openModal = false
  195. },
  196. // 删除
  197. handleDel (row) {
  198. const _this = this
  199. this.$confirm({
  200. title: '提示',
  201. content: '确认要删除吗?',
  202. centered: true,
  203. onOk () {
  204. // salesDel({ id: row.id }).then(res => {
  205. // if (res.status == 200) {
  206. // _this.$message.success(res.message)
  207. // _this.$refs.table.refresh()
  208. // }
  209. // })
  210. }
  211. })
  212. },
  213. // 产品分类 change
  214. changeProductType (val, opt) {
  215. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  216. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  217. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  218. },
  219. // 产品品牌 列表
  220. getProductBrand () {
  221. dealerProductBrandQuery({}).then(res => {
  222. if (res.status == 200) {
  223. this.productBrandList = res.data
  224. } else {
  225. this.productBrandList = []
  226. }
  227. })
  228. },
  229. // 产品分类 列表
  230. getProductType () {
  231. dealerProductTypeQuery({}).then(res => {
  232. if (res.status == 200) {
  233. this.productTypeList = res.data
  234. } else {
  235. this.productTypeList = []
  236. }
  237. })
  238. }
  239. },
  240. activated () {
  241. // 如果是新页签打开,则重置当前页面
  242. if (this.$store.state.app.isNewTab) {
  243. this.resetSearchForm()
  244. }
  245. },
  246. beforeRouteEnter (to, from, next) {
  247. next(vm => {
  248. vm.getProductBrand()
  249. vm.getProductType()
  250. })
  251. }
  252. }
  253. </script>