|
@@ -56,7 +56,10 @@
|
|
|
</el-form-item> -->
|
|
|
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" @click="submitForm('ruleForm')"
|
|
|
+ <el-button type="primary" @click="updateForm('ruleForm')" v-if="isUpdate"
|
|
|
+ >修改</el-button
|
|
|
+ >
|
|
|
+ <el-button type="primary" @click="submitForm('ruleForm')" v-else
|
|
|
>提交</el-button
|
|
|
>
|
|
|
<el-button @click="resetForm('ruleForm')">重置</el-button>
|
|
@@ -68,10 +71,11 @@
|
|
|
<script>
|
|
|
import { getLocation } from "@/api/location";
|
|
|
import { getLevel } from "@/api/level";
|
|
|
-import {addMessage} from '@/api/message'
|
|
|
+import {addMessage,showMessage,upMessage} from '@/api/message'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ isUpdate:false,
|
|
|
ruleForm: {
|
|
|
uname: "",
|
|
|
addressid: "",
|
|
@@ -132,10 +136,64 @@ export default {
|
|
|
resetForm(formName) {
|
|
|
this.$refs[formName].resetFields();
|
|
|
},
|
|
|
+ //根据id获取信息
|
|
|
+ showMessageList(id){
|
|
|
+ console.log(id)
|
|
|
+ showMessage({
|
|
|
+ id: id
|
|
|
+ }).then((res)=>{
|
|
|
+ console.log(res.data[0])
|
|
|
+ // this.ruleForm = res.data[0]
|
|
|
+ let _data = res.data[0]
|
|
|
+ this.ruleForm = {
|
|
|
+ uname: _data.jrname,
|
|
|
+ addressid: _data.jraddressesid,
|
|
|
+ levelid: _data.jrlevel,
|
|
|
+ tel: _data.jrtel
|
|
|
+ }
|
|
|
+ }).catch((err)=>{
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //修改信息
|
|
|
+ updateForm(formName) {
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ upMessage({
|
|
|
+ id: this.$route.query.id,
|
|
|
+ uname: this.ruleForm.uname,
|
|
|
+ addressid: this.ruleForm.addressid,
|
|
|
+ levelid: this.ruleForm.levelid,
|
|
|
+ tel: this.ruleForm.tel,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: res.message,
|
|
|
+ });
|
|
|
+ this.$refs[formName].resetFields();
|
|
|
+ this.$router.push("/message/messageList");
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log("error submit!!");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
},
|
|
|
created() {
|
|
|
this.getLocationList();
|
|
|
this.getLevelList();
|
|
|
+ this.showMessageList()
|
|
|
+ // console.log(this.$route.query.id)
|
|
|
+ if(this.$route.query.id){
|
|
|
+ let _id = this.$route.query.id
|
|
|
+ this.showMessageList(_id),
|
|
|
+ this.isUpdate = true
|
|
|
+ }
|
|
|
},
|
|
|
};
|
|
|
</script>
|