goodsList.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <a-card :bordered="false" class="goodsList-table-page-wrapper">
  3. <div class="goodsList-searchForm">
  4. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  5. <a-row :gutter="48">
  6. <a-col :span="6">
  7. <a-form-item label="商品名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  8. <a-input id="goodsList-name" allowClear v-decorator="[ 'queryParam.name', { initialValue: queryParam.name, getValueFromEvent: $filterEmpty, rules: [] }]" :maxLength="30" placeholder="请输入商品名称" />
  9. </a-form-item>
  10. </a-col>
  11. <a-col :span="6">
  12. <a-form-item label="商品分类" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  13. <v-select
  14. v-model="queryParam.goodsType"
  15. ref="goodsStatus"
  16. id="goodsList-type"
  17. code="SETTLE_STATUS_ALL"
  18. placeholder="请选择商品状态"
  19. allowClear></v-select>
  20. </a-form-item>
  21. </a-col>
  22. <a-col :span="6">
  23. <a-form-item label="供货商" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  24. <a-input id="goodsList-supplierName" allowClear v-decorator="[ 'queryParam.supplierName', { initialValue: queryParam.supplierName, getValueFromEvent: $filterEmpty, rules: [] }]" :maxLength="30" placeholder="请输入供货商" />
  25. </a-form-item>
  26. </a-col>
  27. <a-col :span="6">
  28. <a-form-item label="商品状态" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
  29. <v-select
  30. v-model="queryParam.goodsStatus"
  31. ref="goodsStatus"
  32. id="goodsList-status"
  33. code="SETTLE_STATUS_ALL"
  34. placeholder="请选择商品状态"
  35. allowClear></v-select>
  36. </a-form-item>
  37. </a-col>
  38. <a-col :span="6">
  39. <a-button class="handle-btn serach-btn" id="goodsList-btn-serach" type="primary" @click="$refs.table.refresh(true)">查询</a-button>
  40. <a-button class="handle-btn" type="" id="goodsList-btn-reset" @click="handleReset">重置</a-button>
  41. </a-col>
  42. </a-row>
  43. </a-form>
  44. </div>
  45. <a-divider />
  46. <div class="table-operator">
  47. <a-button id="goodsList-btn-add" type="primary" icon="plus" @click="handleGoods('add')">新增</a-button>
  48. </div>
  49. <s-table
  50. ref="table"
  51. size="default"
  52. :rowKey="(record) => record.id"
  53. :columns="columns"
  54. :data="loadData"
  55. bordered>
  56. <!-- 商品状态 -->
  57. <template slot="orderStatus" slot-scope="text, record">
  58. <span>{{ record.orderStatus==1 ? '已启用' : '已禁用' }}</span>
  59. </template>
  60. <!-- 操作 -->
  61. <template slot="action" slot-scope="text, record">
  62. <a-button id="goodsList-btn-edit" class="icon-blues" type="link" @click="handleGoods('edit', record)">编辑</a-button>
  63. <a-button id="goodsList-btn-shelves" class="icon-orange" type="link" @click="handleShelves(record)">上架</a-button>
  64. <a-button id="goodsList-btn-delect" class="icon-red" type="link" @click="handleDel(record)">删除</a-button>
  65. </template>
  66. </s-table>
  67. </a-card>
  68. </template>
  69. <script>
  70. import { STable, VSelect } from '@/components'
  71. export default {
  72. name: 'GoodsList',
  73. components: { STable, VSelect },
  74. data () {
  75. return {
  76. // 查询参数
  77. queryParam: {
  78. name: '', // 商品名称
  79. supplierName: '', // 供货商
  80. goodsType: null, // 商品分类
  81. goodsStatus: '' // 商品状态
  82. },
  83. loading: false, // 导出loading
  84. // 表头
  85. columns: [
  86. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  87. { title: '商品名称', dataIndex: 'orderDate', width: 200, align: 'center' },
  88. { title: '商品价格(乐豆)', dataIndex: 'userMoblie', width: 200, align: 'center' },
  89. { title: '供货商', dataIndex: 'orderNo', width: 200, align: 'center' },
  90. { title: '商品状态', scopedSlots: { customRender: 'orderStatus' }, width: 200, align: 'center' },
  91. { title: '库存数量', dataIndex: 'orderPrice', width: 200, align: 'center' },
  92. { title: '已售数量', dataIndex: 'orderNum', width: 100, align: 'center' },
  93. { title: '操作', scopedSlots: { customRender: 'action' }, width: 200, align: 'center' }
  94. ],
  95. // 加载数据方法 必须为 Promise 对象
  96. loadData: parameter => {
  97. // return getTenantsList(Object.assign(parameter, this.queryParam)).then(res => {
  98. // if (res.status == 200) {
  99. // const no = (res.data.pageNo - 1) * res.data.pageSize
  100. // for (let i = 0; i < res.data.list.length; i++) {
  101. // const _item = res.data.list[i]
  102. // _item.no = no + i + 1
  103. // _item.status = _item.status + '' === '1'
  104. // }
  105. // return res.data
  106. // }
  107. // })
  108. return new Promise((resolve) => {
  109. const data = [
  110. { no: 1, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '1', orderPrice: '155', orderNum: '67' },
  111. { no: 2, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '0', orderPrice: '155', orderNum: '67' },
  112. { no: 3, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '1', orderPrice: '155', orderNum: '67' },
  113. { no: 4, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '1', orderPrice: '155', orderNum: '67' },
  114. { no: 5, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '0', orderPrice: '155', orderNum: '67' },
  115. { no: 6, orderDate: '2020-10-30 09:14', userMoblie: '15709252525', orderNo: 'NO54456798', orderStatus: '0', orderPrice: '155', orderNum: '67' }
  116. ]
  117. resolve(data)
  118. })
  119. }
  120. }
  121. },
  122. beforeRouteEnter (to, from, next) {
  123. next(vm => {
  124. vm.handleReset()
  125. })
  126. },
  127. methods: {
  128. // 新增、编辑商品
  129. handleGoods (type, row) {
  130. if (type == 'add') {
  131. this.$router.push({ path: '/shop/goods/add' })
  132. } else if (type == 'edit') {
  133. this.$router.push({ path: `/shop/goods/edit/${row.no}` })
  134. }
  135. },
  136. // 删除商品
  137. handleDel (row) {
  138. const _this = this
  139. this.$confirm({
  140. title: '提示',
  141. centered: true,
  142. content: '删除后原数据不可恢复,是否删除?',
  143. okText: '确定',
  144. cancelText: '取消',
  145. onOk () {
  146. // tenantsDelete({
  147. // id: row.id
  148. // }).then(res => {
  149. // if (res.status == 200) {
  150. // _this.$message.success('res.message')
  151. // _this.$refs.table.refresh()
  152. // }
  153. // })
  154. }
  155. })
  156. },
  157. // 上下架
  158. handleShelves (row) {
  159. console.log(row, '---上下架')
  160. },
  161. // 重置
  162. handleReset () {
  163. this.queryParam.name = ''
  164. this.queryParam.supplierName = ''
  165. this.queryParam.goodsStatus = null
  166. this.$refs.table.refresh(true)
  167. }
  168. }
  169. }
  170. </script>
  171. <style lang="less" scoped>
  172. .goodsList-table-page-wrapper{
  173. .goodsList-searchForm{
  174. .ant-form-inline .ant-form-item{
  175. width: 100%;
  176. }
  177. // 搜索框的下间距
  178. .ant-form-item {
  179. margin-bottom: 10px;
  180. }
  181. .handle-btn{
  182. margin-top: 4px;
  183. }
  184. .serach-btn{
  185. margin-right: 10px;
  186. }
  187. }
  188. .export-btn{
  189. background-color: #ff9900;
  190. border-color: #ff9900;
  191. color: #fff;
  192. }
  193. .export-btn.ant-btn:focus:not(.ant-btn-primary):not(.ant-btn-danger), .export-btn.ant-btn:hover:not(.ant-btn-primary):not(.ant-btn-danger){
  194. color: #fff;
  195. border-color: #ff9900;
  196. }
  197. .actionBtn {
  198. font-size: 20px;
  199. padding: 0 10px;
  200. }
  201. .blue {
  202. color: #1890FF;
  203. }
  204. .green {
  205. color: #16b50e;
  206. }
  207. .red {
  208. color: red;
  209. }
  210. }
  211. </style>