|
|
@@ -8,7 +8,6 @@
|
|
|
<el-input clearable class="filter-item" style="width: 200px;" placeholder="请输入商品ID" v-model="listQuery.goodsId">
|
|
|
</el-input>
|
|
|
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">查找</el-button>
|
|
|
- <el-button class="filter-item" type="primary" @click="handleCreate" icon="el-icon-edit">添加</el-button>
|
|
|
<el-button class="filter-item" type="primary" :loading="downloadLoading" icon="el-icon-download" @click="handleDownload">导出</el-button>
|
|
|
</div>
|
|
|
|
|
|
@@ -26,12 +25,6 @@
|
|
|
<el-table-column align="center" min-width="100px" label="添加时间" prop="addTime">
|
|
|
</el-table-column>
|
|
|
|
|
|
- <el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width">
|
|
|
- <template slot-scope="scope">
|
|
|
- <el-button type="primary" size="mini" @click="handleUpdate(scope.row)">编辑</el-button>
|
|
|
- <el-button type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
|
|
|
- </template>
|
|
|
- </el-table-column>
|
|
|
</el-table>
|
|
|
|
|
|
<!-- 分页 -->
|
|
|
@@ -41,32 +34,11 @@
|
|
|
</el-pagination>
|
|
|
</div>
|
|
|
|
|
|
- <!-- 添加或修改对话框 -->
|
|
|
- <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible">
|
|
|
- <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="100px" style='width: 400px; margin-left:50px;'>
|
|
|
- <el-form-item label="用户ID" prop="userId">
|
|
|
- <el-input v-model="dataForm.userId"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="商品ID" prop="goodsId">
|
|
|
- <el-input v-model="dataForm.goodsId"></el-input>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="添加时间" prop="addTime">
|
|
|
- <el-date-picker v-model="dataForm.addTime" type="date" placeholder="选择日期" value-format="yyyy-MM-dd">
|
|
|
- </el-date-picker>
|
|
|
- </el-form-item>
|
|
|
- </el-form>
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="dialogFormVisible = false">取消</el-button>
|
|
|
- <el-button v-if="dialogStatus=='create'" type="primary" @click="createData">确定</el-button>
|
|
|
- <el-button v-else type="primary" @click="updateData">确定</el-button>
|
|
|
- </div>
|
|
|
- </el-dialog>
|
|
|
-
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listFootprint, createFootprint, updateFootprint, deleteFootprint } from '@/api/footprint'
|
|
|
+import { listFootprint } from '@/api/footprint'
|
|
|
|
|
|
export default {
|
|
|
name: 'FootPrint',
|
|
|
@@ -83,22 +55,6 @@ export default {
|
|
|
sort: 'add_time',
|
|
|
order: 'desc'
|
|
|
},
|
|
|
- dataForm: {
|
|
|
- id: undefined,
|
|
|
- userId: '',
|
|
|
- goodsId: '',
|
|
|
- addTime: undefined
|
|
|
- },
|
|
|
- dialogFormVisible: false,
|
|
|
- dialogStatus: '',
|
|
|
- textMap: {
|
|
|
- update: '编辑',
|
|
|
- create: '创建'
|
|
|
- },
|
|
|
- rules: {
|
|
|
- userId: [{ required: true, message: '用户ID不能为空', trigger: 'blur' }],
|
|
|
- goodsId: [{ required: true, message: '商品ID不能为空', trigger: 'blur' }]
|
|
|
- },
|
|
|
downloadLoading: false
|
|
|
}
|
|
|
},
|
|
|
@@ -130,80 +86,6 @@ export default {
|
|
|
this.listQuery.page = val
|
|
|
this.getList()
|
|
|
},
|
|
|
- resetForm() {
|
|
|
- this.dataForm = {
|
|
|
- id: undefined,
|
|
|
- userId: '',
|
|
|
- goodsId: '',
|
|
|
- addTime: undefined
|
|
|
- }
|
|
|
- },
|
|
|
- handleCreate() {
|
|
|
- this.resetForm()
|
|
|
- this.dialogStatus = 'create'
|
|
|
- this.dialogFormVisible = true
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs['dataForm'].clearValidate()
|
|
|
- })
|
|
|
- },
|
|
|
- createData() {
|
|
|
- this.$refs['dataForm'].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- createFootprint(this.dataForm).then(response => {
|
|
|
- this.list.unshift(response.data.data)
|
|
|
- this.dialogFormVisible = false
|
|
|
- this.$notify({
|
|
|
- title: '成功',
|
|
|
- message: '创建成功',
|
|
|
- type: 'success',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- handleUpdate(row) {
|
|
|
- this.dataForm = Object.assign({}, row)
|
|
|
- this.dialogStatus = 'update'
|
|
|
- this.dialogFormVisible = true
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$refs['dataForm'].clearValidate()
|
|
|
- })
|
|
|
- },
|
|
|
- updateData() {
|
|
|
- this.$refs['dataForm'].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- updateFootprint(this.dataForm).then(() => {
|
|
|
- for (const v of this.list) {
|
|
|
- if (v.id === this.dataForm.id) {
|
|
|
- const index = this.list.indexOf(v)
|
|
|
- this.list.splice(index, 1, this.dataForm)
|
|
|
- break
|
|
|
- }
|
|
|
- }
|
|
|
- this.dialogFormVisible = false
|
|
|
- this.$notify({
|
|
|
- title: '成功',
|
|
|
- message: '更新成功',
|
|
|
- type: 'success',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- handleDelete(row) {
|
|
|
- deleteFootprint(row).then(response => {
|
|
|
- this.$notify({
|
|
|
- title: '成功',
|
|
|
- message: '删除成功',
|
|
|
- type: 'success',
|
|
|
- duration: 2000
|
|
|
- })
|
|
|
- const index = this.list.indexOf(row)
|
|
|
- this.list.splice(index, 1)
|
|
|
- })
|
|
|
- },
|
|
|
handleDownload() {
|
|
|
this.downloadLoading = true
|
|
|
import('@/vendor/Export2Excel').then(excel => {
|