|
@@ -208,169 +208,169 @@
|
|
|
var vue = new Vue({
|
|
|
el: '#app',
|
|
|
data:{
|
|
|
- pagination: {//分页相关模型数据
|
|
|
- currentPage: 1,//当前页码
|
|
|
- pageSize:10,//每页显示的记录数
|
|
|
- total:0,//总记录数
|
|
|
- queryString:null//查询条件
|
|
|
- },
|
|
|
- dataList: [],//当前页要展示的分页列表数据
|
|
|
- formData: {},//表单数据
|
|
|
- dialogFormVisible: false,//增加表单是否可见
|
|
|
- dialogFormVisible4Edit:false,//编辑表单是否可见
|
|
|
- rules: {//校验规则
|
|
|
- code: [{ required: true, message: '项目编码为必填项', trigger: 'blur' }],
|
|
|
- name: [{ required: true, message: '项目名称为必填项', trigger: 'blur' }]
|
|
|
- }
|
|
|
+ pagination: {//分页相关模型数据
|
|
|
+ currentPage: 1,//当前页码
|
|
|
+ pageSize:20,//每页显示的记录数
|
|
|
+ total:0,//总记录数
|
|
|
+ queryString:null//查询条件
|
|
|
+ },
|
|
|
+ dataList: [],//当前页要展示的分页列表数据
|
|
|
+ formData: {},//表单数据
|
|
|
+ dialogFormVisible: false,//增加表单是否可见
|
|
|
+ dialogFormVisible4Edit:false,//编辑表单是否可见
|
|
|
+ rules: {//校验规则
|
|
|
+ code: [{ required: true, message: '项目编码为必填项', trigger: 'blur' }],
|
|
|
+ name: [{ required: true, message: '项目名称为必填项', trigger: 'blur' }]
|
|
|
+ }
|
|
|
},
|
|
|
//钩子函数,VUE对象初始化完成后自动执行
|
|
|
created() {
|
|
|
- //获取数据
|
|
|
- this.findPage()
|
|
|
+ //获取数据
|
|
|
+ this.findPage()
|
|
|
},
|
|
|
methods: {
|
|
|
- //编辑
|
|
|
- handleEdit() {
|
|
|
- t = this;
|
|
|
- this.$refs['dataEditForm'].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- //提交 fromData
|
|
|
- axios.post(`/travelitem/edit.do`,this.formData)
|
|
|
- .then( res => {
|
|
|
- if(res.data.flag){
|
|
|
- //添加成功提示
|
|
|
- t.$message.success(res.data.message)
|
|
|
- //关闭添加窗口
|
|
|
- t.dialogFormVisible4Edit = false
|
|
|
- //重置表单
|
|
|
- this.resetForm()
|
|
|
- }else{
|
|
|
- t.$message.error(res.data.message);
|
|
|
- }
|
|
|
- }).finally(()=> {
|
|
|
- // 刷新页面(列表查询)
|
|
|
- this.findPage()
|
|
|
- });
|
|
|
-
|
|
|
- } else {
|
|
|
- console.log('error submit!!');
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- //添加
|
|
|
- handleAdd () {
|
|
|
- t = this;
|
|
|
- this.$refs['dataAddForm'].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- //提交 fromData
|
|
|
- axios.put(`/travelitem/add.do`,this.formData)
|
|
|
- .then( res => {
|
|
|
- if(res.data.flag){
|
|
|
- //添加成功提示
|
|
|
- t.$message.success(res.data.message)
|
|
|
- //关闭添加窗口
|
|
|
- t.dialogFormVisible = false
|
|
|
- //重置
|
|
|
- this.resetForm()
|
|
|
- }else{
|
|
|
- t.$message.error(res.data.message);
|
|
|
- }
|
|
|
- }).finally(()=> {
|
|
|
- // 刷新页面(列表查询)
|
|
|
- this.findPage()
|
|
|
- });
|
|
|
-
|
|
|
- } else {
|
|
|
- console.log('error submit!!');
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- },
|
|
|
- //分页查询
|
|
|
- findPage() {
|
|
|
- //参数
|
|
|
- let params = {
|
|
|
- currentPage: this.pagination.currentPage,//当前页码
|
|
|
- pageSize:this.pagination.pageSize,//每页显示的记录数
|
|
|
- queryString:{
|
|
|
- 'name':this.pagination.queryString
|
|
|
- }//查询条件
|
|
|
- }
|
|
|
- //发送请求
|
|
|
- axios.post(`/travelitem/findPage.do`, params)
|
|
|
- .then(res =>{
|
|
|
- //赋值
|
|
|
- console.log(res)
|
|
|
-
|
|
|
- this.dataList = res.data.data.rows;
|
|
|
- this.pagination.total = res.data.data.total;
|
|
|
- })
|
|
|
- },
|
|
|
- // 重置表单
|
|
|
- resetForm() {
|
|
|
- this.formData = {}
|
|
|
- },
|
|
|
- // 弹出添加窗口
|
|
|
- handleCreate() {
|
|
|
-
|
|
|
- //重置表单
|
|
|
- this.resetForm()
|
|
|
- this.dialogFormVisible = true
|
|
|
- },
|
|
|
- // 弹出编辑窗口
|
|
|
- handleUpdate(row) {
|
|
|
- console.log(row)
|
|
|
- //开启弹窗
|
|
|
- this.dialogFormVisible4Edit = true
|
|
|
- //发送请求 进行回显
|
|
|
- axios.get(`/travelitem/selectById.do?id=${row.id}`).then( res => {
|
|
|
-
|
|
|
- console.log(res.data)
|
|
|
- this.formData = res.data.data
|
|
|
- })
|
|
|
-
|
|
|
- },
|
|
|
- //切换页码
|
|
|
- handleCurrentChange(currentPage) {
|
|
|
- // currentPage为切换后的页码
|
|
|
- this.pagination.currentPage = currentPage;
|
|
|
- this.findPage();
|
|
|
- },
|
|
|
- // 删除
|
|
|
- handleDelete(row) {
|
|
|
- this.$confirm('此操作将永久删除该自由行, 是否继续?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning',
|
|
|
- center: true
|
|
|
- }).then(() => {
|
|
|
- // 发送ajax请求,执行删除
|
|
|
- axios.get(`/travelitem/delete.do?id=${row.id}`)
|
|
|
- .then( res =>{
|
|
|
- console.log(res)
|
|
|
- if(res.data.flag){
|
|
|
- this.$message({
|
|
|
- type: 'success',
|
|
|
- message: res.data.message
|
|
|
- });
|
|
|
- //刷新页面
|
|
|
- this.findPage();
|
|
|
- }else{
|
|
|
- this.$message({
|
|
|
- type: 'error',
|
|
|
- message: res.data.message
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- }).catch(() => {
|
|
|
- this.$message({
|
|
|
- type: 'info',
|
|
|
- message: '已取消删除'
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
+ //编辑
|
|
|
+ handleEdit() {
|
|
|
+ t = this;
|
|
|
+ this.$refs['dataEditForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ //提交 fromData
|
|
|
+ axios.post(`/travelitem/edit.do`,this.formData)
|
|
|
+ .then( res => {
|
|
|
+ if(res.data.flag){
|
|
|
+ //添加成功提示
|
|
|
+ t.$message.success(res.data.message)
|
|
|
+ //关闭添加窗口
|
|
|
+ t.dialogFormVisible4Edit = false
|
|
|
+ //重置表单
|
|
|
+ this.resetForm()
|
|
|
+ }else{
|
|
|
+ t.$message.error(res.data.message);
|
|
|
+ }
|
|
|
+ }).finally(()=> {
|
|
|
+ // 刷新页面(列表查询)
|
|
|
+ this.findPage()
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //添加
|
|
|
+ handleAdd () {
|
|
|
+ t = this;
|
|
|
+ this.$refs['dataAddForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ //提交 fromData
|
|
|
+ axios.put(`/travelitem/add.do`,this.formData)
|
|
|
+ .then( res => {
|
|
|
+ if(res.data.flag){
|
|
|
+ //添加成功提示
|
|
|
+ t.$message.success(res.data.message)
|
|
|
+ //关闭添加窗口
|
|
|
+ t.dialogFormVisible = false
|
|
|
+ //重置
|
|
|
+ this.resetForm()
|
|
|
+ }else{
|
|
|
+ t.$message.error(res.data.message);
|
|
|
+ }
|
|
|
+ }).finally(()=> {
|
|
|
+ // 刷新页面(列表查询)
|
|
|
+ this.findPage()
|
|
|
+ });
|
|
|
+
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //分页查询
|
|
|
+ findPage() {
|
|
|
+ //参数
|
|
|
+ let params = {
|
|
|
+ currentPage: this.pagination.currentPage,//当前页码
|
|
|
+ pageSize:this.pagination.pageSize,//每页显示的记录数
|
|
|
+ queryString:{
|
|
|
+ 'name':this.pagination.queryString
|
|
|
+ }//查询条件
|
|
|
+ }
|
|
|
+ //发送请求
|
|
|
+ axios.post(`/travelitem/findPage.do`, params)
|
|
|
+ .then(res =>{
|
|
|
+ //赋值
|
|
|
+ console.log(res)
|
|
|
+
|
|
|
+ this.dataList = res.data.data.rows;
|
|
|
+ this.pagination.total = res.data.data.total;
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 重置表单
|
|
|
+ resetForm() {
|
|
|
+ this.formData = {}
|
|
|
+ },
|
|
|
+ // 弹出添加窗口
|
|
|
+ handleCreate() {
|
|
|
+
|
|
|
+ //重置表单
|
|
|
+ this.resetForm()
|
|
|
+ this.dialogFormVisible = true
|
|
|
+ },
|
|
|
+ // 弹出编辑窗口
|
|
|
+ handleUpdate(row) {
|
|
|
+ console.log(row)
|
|
|
+ //开启弹窗
|
|
|
+ this.dialogFormVisible4Edit = true
|
|
|
+ //发送请求 进行回显
|
|
|
+ axios.get(`/travelitem/selectById.do?id=${row.id}`).then( res => {
|
|
|
+
|
|
|
+ console.log(res.data)
|
|
|
+ this.formData = res.data.data
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ //切换页码
|
|
|
+ handleCurrentChange(currentPage) {
|
|
|
+ // currentPage为切换后的页码
|
|
|
+ this.pagination.currentPage = currentPage;
|
|
|
+ this.findPage();
|
|
|
+ },
|
|
|
+ // 删除
|
|
|
+ handleDelete(row) {
|
|
|
+ this.$confirm('此操作将永久删除该自由行, 是否继续?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ center: true
|
|
|
+ }).then(() => {
|
|
|
+ // 发送ajax请求,执行删除
|
|
|
+ axios.get(`/travelitem/delete.do?id=${row.id}`)
|
|
|
+ .then( res =>{
|
|
|
+ console.log(res)
|
|
|
+ if(res.data.flag){
|
|
|
+ this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: res.data.message
|
|
|
+ });
|
|
|
+ //刷新页面
|
|
|
+ this.findPage();
|
|
|
+ }else{
|
|
|
+ this.$message({
|
|
|
+ type: 'error',
|
|
|
+ message: res.data.message
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }).catch(() => {
|
|
|
+ this.$message({
|
|
|
+ type: 'info',
|
|
|
+ message: '已取消删除'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
</script>
|