|
@@ -34,12 +34,16 @@
|
|
|
<el-input v-model="ruleForm.tel" />
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" @click="submitForm('ruleForm')" v-if="open"
|
|
|
- >修改</el-button
|
|
|
- >
|
|
|
- <el-button type="primary" @click="submitForm('ruleForm')" v-else
|
|
|
- >提交</el-button
|
|
|
- >
|
|
|
+ <el-button
|
|
|
+ v-if="open"
|
|
|
+ type="primary"
|
|
|
+ @click="submitForm('ruleForm')"
|
|
|
+ >修改</el-button>
|
|
|
+ <el-button
|
|
|
+ v-else
|
|
|
+ type="primary"
|
|
|
+ @click="submitForm('ruleForm')"
|
|
|
+ >提交</el-button>
|
|
|
<el-button @click="resetForm('ruleForm')">重置</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
@@ -47,83 +51,85 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { showAddresses } from "@/api/address.js";
|
|
|
-import { showLevel } from "@/api/level.js";
|
|
|
+import { showAddresses } from '@/api/address.js'
|
|
|
+import { showLevel } from '@/api/level.js'
|
|
|
import {
|
|
|
insertAllMessage,
|
|
|
showOneMessage,
|
|
|
- updateMessage,
|
|
|
-} from "@/api/message.js";
|
|
|
+ updateMessage
|
|
|
+} from '@/api/message.js'
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
ruleForm: {
|
|
|
- uname: "",
|
|
|
- addressid: "",
|
|
|
- levelid: "",
|
|
|
- tel: "",
|
|
|
- arr1: "",
|
|
|
+ uname: '',
|
|
|
+ addressid: '',
|
|
|
+ levelid: '',
|
|
|
+ tel: '',
|
|
|
+ arr1: ''
|
|
|
},
|
|
|
addressList: [],
|
|
|
levelList: [],
|
|
|
rules: {
|
|
|
- uname: [{ required: true, message: "请输入用户名称", trigger: "blur" }],
|
|
|
+ uname: [{ required: true, message: '请输入用户名称', trigger: 'blur' }],
|
|
|
addressid: [
|
|
|
- { required: true, message: "请选择地址名称", trigger: "change" },
|
|
|
+ { required: true, message: '请选择地址名称', trigger: 'change' }
|
|
|
],
|
|
|
- tel: [{ required: true, message: "请输入电话号码", trigger: "blur" }],
|
|
|
+ tel: [{ required: true, message: '请输入电话号码', trigger: 'blur' }],
|
|
|
levelid: [
|
|
|
- { required: true, message: "请选择等级名称", trigger: "change" },
|
|
|
- ],
|
|
|
+ { required: true, message: '请选择等级名称', trigger: 'change' }
|
|
|
+ ]
|
|
|
},
|
|
|
- id: "",
|
|
|
- open: false,
|
|
|
- };
|
|
|
+ id: '',
|
|
|
+ open: false
|
|
|
+ }
|
|
|
},
|
|
|
created() {
|
|
|
- this.id = this.$route.query.ids;
|
|
|
+ this.id = this.$route.query.ids
|
|
|
+ console.log(this.id,'id')
|
|
|
if (this.id) {
|
|
|
- this.open = true;
|
|
|
+ this.open = true
|
|
|
showOneMessage({
|
|
|
- id: this.id,
|
|
|
+ id: this.id
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- if (res.code == 101) {
|
|
|
- this.ruleForm.uname = res.data[0].jrname;
|
|
|
- this.ruleForm.addressid = res.data[0].jraddressesid;
|
|
|
- this.ruleForm.tel = res.data[0].jrtel;
|
|
|
- this.ruleForm.levelid = res.data[0].jrlevel;
|
|
|
+ console.log(res,'res')
|
|
|
+ if (res.code == 200) {
|
|
|
+ this.ruleForm.uname = res.data.records[0].jrname
|
|
|
+ this.ruleForm.addressid = res.data.records[0].jraddressesid
|
|
|
+ this.ruleForm.tel = res.data.records[0].jrtel
|
|
|
+ this.ruleForm.levelid = res.data.records[0].jrlevel
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
} else {
|
|
|
- this.open = false;
|
|
|
+ this.open = false
|
|
|
}
|
|
|
- this.getAddress();
|
|
|
- this.getLevel();
|
|
|
+ this.getAddress()
|
|
|
+ this.getLevel()
|
|
|
},
|
|
|
methods: {
|
|
|
// 获取所有地址
|
|
|
getAddress() {
|
|
|
showAddresses()
|
|
|
.then((res) => {
|
|
|
- this.addressList = res.data;
|
|
|
+ this.addressList = res.data.records
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
},
|
|
|
// 获取所有等级
|
|
|
getLevel() {
|
|
|
showLevel()
|
|
|
.then((res) => {
|
|
|
- this.levelList = res.data;
|
|
|
+ this.levelList = res.data.records
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
},
|
|
|
submitForm(formName) {
|
|
|
this.$refs[formName].validate((valid) => {
|
|
@@ -131,58 +137,58 @@ export default {
|
|
|
if (this.open) {
|
|
|
// 修改
|
|
|
updateMessage({
|
|
|
- id: this.id,
|
|
|
- uname: this.ruleForm.uname,
|
|
|
- addressid: this.ruleForm.addressid,
|
|
|
- levelid: this.ruleForm.levelid,
|
|
|
- tel: this.ruleForm.tel,
|
|
|
+ jrid: this.id,
|
|
|
+ jrname: this.ruleForm.uname,
|
|
|
+ jraddressesid: this.ruleForm.addressid,
|
|
|
+ jrlevel: this.ruleForm.levelid,
|
|
|
+ jrtel: this.ruleForm.tel
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- if (res.code == 101) {
|
|
|
+ if (res.code == 200) {
|
|
|
this.$message({
|
|
|
message: res.message,
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- this.resetForm("ruleForm");
|
|
|
- this.$router.push("./messageList");
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ this.resetForm('ruleForm')
|
|
|
+ this.$router.push('./messageList')
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log(err, "失败");
|
|
|
- });
|
|
|
+ console.log(err, '失败')
|
|
|
+ })
|
|
|
} else {
|
|
|
// 添加
|
|
|
insertAllMessage({
|
|
|
- uname: this.ruleForm.uname,
|
|
|
- addressid: this.ruleForm.addressid,
|
|
|
- levelid: this.ruleForm.levelid,
|
|
|
- tel: this.ruleForm.tel,
|
|
|
+ jrname: this.ruleForm.uname,
|
|
|
+ jraddressesid: this.ruleForm.addressid,
|
|
|
+ jrlevel: this.ruleForm.levelid,
|
|
|
+ jrtel: this.ruleForm.tel
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- if (res.code == 101) {
|
|
|
+ if (res.code == 200) {
|
|
|
this.$message({
|
|
|
message: res.message,
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- this.resetForm("ruleForm");
|
|
|
- this.$router.push("./messageList");
|
|
|
+ type: 'success'
|
|
|
+ })
|
|
|
+ this.resetForm('ruleForm')
|
|
|
+ this.$router.push('./messageList')
|
|
|
}
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
}
|
|
|
} else {
|
|
|
- console.log("error submit!!");
|
|
|
- return false;
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
resetForm(formName) {
|
|
|
- this.$refs[formName].resetFields();
|
|
|
- },
|
|
|
- },
|
|
|
-};
|
|
|
+ this.$refs[formName].resetFields()
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|