|
@@ -30,8 +30,13 @@ export default {
|
|
|
expirationTime: '',
|
|
|
id: '',
|
|
|
cardNo: '',
|
|
|
+ oldCardNo: '',
|
|
|
communityId: '',
|
|
|
- type: this.params.type
|
|
|
+ type: this.params.type,
|
|
|
+ cardType: '',
|
|
|
+ userId: '',
|
|
|
+ userName: '',
|
|
|
+ houseId: ''
|
|
|
},
|
|
|
formRules: {
|
|
|
expirationTime: [this.$valid.selectRequired('到期时间')],
|
|
@@ -65,8 +70,12 @@ export default {
|
|
|
this.$http.get('/sc-gate-web/gateCard/find/' + id).then(({ msg, data, status }) => {
|
|
|
if (status == 0) {
|
|
|
this.formData.id = data.id;
|
|
|
- this.formData.cardNo = data.cardNo;
|
|
|
+ this.formData.oldCardNo = data.cardNo;
|
|
|
this.formData.communityId = data.communityId;
|
|
|
+ this.formData.cardType = data.cardType;
|
|
|
+ this.formData.userId = data.userId;
|
|
|
+ this.formData.userName = data.username;
|
|
|
+ this.formData.houseId = data.houseId;
|
|
|
this.thisObj = data;
|
|
|
} else {
|
|
|
this.$message.error(msg);
|
|
@@ -81,36 +90,51 @@ export default {
|
|
|
}
|
|
|
this.formData.cardNo = randomNumber.toString().replace(/,/g, '');
|
|
|
},
|
|
|
+ getdepld(id, resolves) {
|
|
|
+ this.$http.get('/sc-gate-web/community/getId', { communityId: id }).then(({ data, status, msg }) => {
|
|
|
+ if (status == 0) {
|
|
|
+ resolves && resolves(data);
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
writeCard(installData) {
|
|
|
- let ids = () => {
|
|
|
- let newAr = [];
|
|
|
- this.thisObj.gateList.map((item) => {
|
|
|
- newAr.push(item.deviceNo);
|
|
|
- });
|
|
|
- return newAr;
|
|
|
- };
|
|
|
- let inFrom = {
|
|
|
- depId: this.params.row.communityId,
|
|
|
- expire_date: installData.expirationTime,
|
|
|
- guids: ids().join(',')
|
|
|
- };
|
|
|
- new Promise((resolve) => {
|
|
|
- this.$http
|
|
|
- .post(`${this.params.row.cardType == 2 ? '/card/issue/manage' : '/card/issue/resident'}`, [inFrom])
|
|
|
- .then(({ data, status, msg }) => {
|
|
|
- if (status == 0) {
|
|
|
- // this.$message.success(msg);
|
|
|
- resolve && resolve();
|
|
|
- } else {
|
|
|
- this.$message.error(msg);
|
|
|
- }
|
|
|
- });
|
|
|
+ new Promise((resolves) => {
|
|
|
+ this.getdepld(this.params.row.communityId, resolves);
|
|
|
}).then((res) => {
|
|
|
- this.isOk(installData);
|
|
|
+ new Promise((resolve) => {
|
|
|
+ let ids = () => {
|
|
|
+ let arr = [];
|
|
|
+ this.thisObj.gateList.map((item) => {
|
|
|
+ arr.push({
|
|
|
+ guids: item.deviceNo,
|
|
|
+ expire_date: installData.expirationTime,
|
|
|
+ depId: res
|
|
|
+ });
|
|
|
+ });
|
|
|
+ return arr;
|
|
|
+ };
|
|
|
+ this.$http
|
|
|
+ .post(`${this.params.row.cardType == 2 ? '/card/issue/manage' : '/card/issue/resident'}`, ids())
|
|
|
+ .then(({ data, status, msg }) => {
|
|
|
+ if (status == 0) {
|
|
|
+ resolve && resolve();
|
|
|
+ } else {
|
|
|
+ this.$message.error(msg);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }).then((res) => {
|
|
|
+ this.isOk(installData);
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
isOk(installData) {
|
|
|
var loading = this.$loading();
|
|
|
+ if(this.params.type == 5){
|
|
|
+ installData.cardNo = installData.oldCardNo
|
|
|
+ delete installData.oldCardNo
|
|
|
+ }
|
|
|
this.$http
|
|
|
.post('/sc-gate-web/gateCard/operate', installData)
|
|
|
.then(({ status, msg }) => {
|