123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- <template>
- <section>
- <section v-loading="loading"
- element-loading-text="拼命加载中……"
- class="bg-white">
- <div class="table-filter-wrapper mar-l-10">
- <ph-form @searchBtn="searchBtn"
- @resetSearchBtn="resetSearchBtn"
- @addHandle="addHandle"
- :searchForm="searchForm">
- </ph-form>
- </div>
- <div class="table-wrapper pad-t-5 bor-t-1">
- <ph-table :tableData="tableData"
- @editHandle="editHandle"
- @singleDeleteHandle="singleDeleteHandle"
- @selectionChangeHandle="selectionChangeHandle">
- </ph-table>
- <el-row class="mar-t-10">
- <el-col :span='4'>
- <el-button @click="batchDeleteHandle()"
- :disabled="isBatchDeleteDisabled"
- size="small">批量删除
- </el-button>
- </el-col>
- <el-col :span='20'>
- <ph-pagination @sendPaginations="sendPaginationsHandle"
- :paginations="paginationParams"
- class="mar-r-20 text-right">
- </ph-pagination>
- </el-col>
- </el-row>
- </div>
- </section>
- <!--新增、编辑-->
- <added-editor-dialog :dialogForm="dialogForm"
- :submitLoading="submitLoading"
- :dialogVisible.sync="addedEditorDialog"
- @getCancel="handleCancel"
- @submitHandle="submitAddedEditorForm">
- </added-editor-dialog>
- </section>
- </template>
- <script>
- import Form from './Form'
- import Table from './Table'
- import Pagination from '@/components/Pagination'
- import AddedEditorDialog from './components/AddedEditorDialog'
- export default {
- name: 'goodsList',
- components: {
- 'ph-pagination': Pagination,
- 'added-editor-dialog': AddedEditorDialog,
- 'ph-form': Form,
- 'ph-table': Table
- },
- data () {
- return {
- loading: false,
- submitLoading: false,
- paginationParams: this.$config.paginationParams,
- handleType: '',
- checkedIds: [],
- isBatchDeleteDisabled: false,
-
- tableData: [{
- name: '小米手机',
- code: 'XMSJ',
- time: 1573625941000
- }, {
- name: '华为手机',
- code: 'HWSJ',
- time: 1573009362000
- }, {
- name: '红米手机',
- code: 'HMSJ',
- time: 1573193112000
- }, {
- name: '荣耀手机',
- code: 'RYSJ',
- time: 1573610740000
- }],
-
- addedEditorDialog: false,
- dialogForm: {
- name: '',
- code: ''
- },
-
- searchForm: {
- name: '',
- code: ''
- }
- }
- },
- created () {
-
-
- },
- methods: {
-
- async successList (params) {
- return this.$message.error("请配置接口!");
- this.loading = true
- let res = await this.$api.systemModule.goodsManage.getList(params)
- let data = res.data.data
- if (res.data.retcode === this.$config.RET_CODE.SUCCESS_CODE) {
- this.loading = false
- if (data.rows.length > 0) {
- this.isBatchDeleteDisabled = false
- this.tableData = data.rows
- this.paginationParams.pageSize = data.pageSize
- this.paginationParams.size = data.size
- this.paginationParams.total = data.total
- this.paginationParams.pages = data.pages
- } else {
- this.tableData = []
- this.paginationParams.total = 0
- this.isBatchDeleteDisabled = true
- }
- } else {
- this.$message({
- type: 'error',
- message: res.data.retmsg
- })
- }
- },
-
- getList () {
- return this.$message.error("请配置接口!");
- let params = {
- pageNo: this.paginationParams.pageNo,
- pageSize: this.paginationParams.pageSize
- }
-
- this.successList(params)
- },
-
- searchBtn (searchData) {
- let params = {
- pageNo: this.paginationParams.pageNo,
- pageSize: this.paginationParams.pageSize,
- name: searchData && searchData.name ? searchData.name : null,
- }
-
- this.successList(params)
- },
-
- sendPaginationsHandle () {
- if (this.searchForm.name !== '' || this.searchForm.code !== '') {
- let params = {
- pageNo: this.paginationParams.pageNo,
- pageSize: this.paginationParams.pageSize,
- name: this.searchForm && this.searchForm.name !== '' ? this.searchForm.name : null,
- }
-
- this.successList(params)
- } else {
- this.getList()
- }
- },
-
- resetSearchBtn () {
- this.searchForm = {}
- this.paginationParams.pageNo = 1
- this.getList()
- },
-
- addHandle () {
- this.handleType = 'add'
- this.addedEditorDialog = true
-
- this.dialogForm = {
- name: '',
- code: ''
- }
- },
-
- selectionChangeHandle (checkedData) {
-
- checkedData.forEach(item => {
- this.checkedIds.push(item.id)
- })
- },
-
- editHandle (index, row) {
- this.handleType = 'edit'
- this.addedEditorDialog = true
- this.dialogForm = {
- name: row.name,
- code: row.code,
- id: row.id
- }
-
- let params = row.id
- return this.$message.error("请配置接口!");
- this.$api.systemModule.goodsManage.getDataById(params)
- .then(res => {
- if (res.data.retcode === this.$config.RET_CODE.SUCCESS_CODE) {
- let data = res.data.data
-
- this.dialogForm = {
- name: data.name,
- code: data.code,
- id: data.id
- }
- } else {
- this.$message({
- type: 'error',
- message: res.data.retmsg
- })
- }
- }).catch(err => {
- console.log(err)
- })
- },
-
- deleteHandle (tipsText, params, cancelTips) {
-
- this.$confirm(tipsText, '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- return this.$message.error("请配置接口!");
-
- this.$api.systemModule.goodsManage.batchEdit(params)
- .then(res => {
- if (res.data.retcode === this.$config.RET_CODE.SUCCESS_CODE) {
- this.$message({
- type: 'success',
- message: res.data.retmsg
- })
- this.getList()
- } else {
- this.$message({
- type: 'error',
- message: res.data.retmsg
- })
- }
- }).catch(err => {
- console.log(err)
- })
- }).catch(() => {
- this.$message({
- type: 'info',
- message: cancelTips
- })
- })
- },
-
- singleDeleteHandle (index, row) {
- let arr = []
- arr.push(row.id)
- let params = {
- ids: [row.id]
- }
- this.deleteHandle('确定删除当前拍品信息?', params, '取消删除')
- },
-
- batchDeleteHandle () {
- if (this.checkedIds.length > 0) {
- let params = {
- ids: this.checkedIds
- }
- this.deleteHandle('确定批量删除当前拍品信息?', params, '取消删除')
- } else {
- this.$message({
- type: 'error',
- message: '请选择拍品'
- })
- }
- },
-
- handleCancel () {
- this.addedEditorDialog = false
- },
-
- submitAddedEditorForm () {
- return this.$message.error("请配置接口!");
- this.submitLoading = true
- let params = this.dialogForm
- if (this.handleType === 'add') {
-
- this.$api.systemModule.goodsManage.add(params)
- .then(res => {
- if (res.data.retcode === this.$config.RET_CODE.SUCCESS_CODE) {
- this.submitLoading = false
- this.$message({
- message: res.data.retmsg,
- type: "success"
- })
- this.getList()
- this.addedEditorDialog = false
- } else {
-
- this.$message({
- message: res.data.retmsg,
- type: "error"
- })
- this.submitLoading = false
- }
- }).catch(err => {
- console.log(err)
- this.addedEditorDialog = false
- this.submitLoading = false
- })
- } else if (this.handleType === 'edit') {
- return this.$message.error("请配置接口!");
-
- this.$api.systemModule.goodsManage.edit(params)
- .then(res => {
- if (res.data.retcode === this.$config.RET_CODE.SUCCESS_CODE) {
- this.submitLoading = false
- this.$message({
- type: "success",
- message: res.data.retmsg
- })
- this.getList()
- this.addedEditorDialog = false
- } else {
-
- this.$message({
- type: "error",
- message: res.data.retmsg
- })
- this.submitLoading = false
- }
- }).catch(err => {
-
- console.log(err)
- this.addedEditorDialog = false
- this.submitLoading = false
- })
- }
- }
- }
- }
- </script>
|