使 点击进入签名的按钮 的handleAddFile方法实现跳转到名为SIGN的页面,使用uni.navigateto
时间: 2024-12-16 14:32:05 浏览: 3
为了实现“点击进入签名”的按钮在点击后跳转到名为 `SIGN` 的页面,可以修改 `handleAddFile` 方法,使用 `uni.navigateTo` 进行页面跳转。具体步骤如下:
1. 在 `methods` 中定义 `handleAddFile` 方法。
2. 使用 `uni.navigateTo` 方法进行页面跳转。
以下是具体的代码实现:
```javascript
methods: {
// 其他方法...
handleAddFile() {
uni.navigateTo({
url: '/pages/SIGN/SIGN'
});
}
}
```
### 完整的方法部分
```javascript
methods: {
async handleCheckPersonAfterRead(file, index) {
let url = file.file.url;
const result = await this.uploadFilePromise(url);
let parsedResult = JSON.parse(result);
this.$set(this.tab1Data.rows[index], 'imgUrl', [{ url }]);
this.$set(this.tab1Data.rows[index], 'fileList', parsedResult.data);
},
handleCheckPersonDelete(index) {
this.$set(this.tab1Data.rows[index], 'fileList', '');
this.$set(this.tab1Data.rows[index], 'imgUrl', []);
},
async handleCheckPersonAfterRead1(file, index) {
let url = file.file.url;
const result = await this.uploadFilePromise(url);
let parsedResult = JSON.parse(result);
this.$set(this.tab1Data.rows[index], 'imgUrl1', [{ url }]);
this.$set(this.tab1Data.rows[index], 'fileList1', parsedResult.data);
},
handleCheckPersonDelete1(index) {
this.$set(this.tab1Data.rows[index], 'fileList1', '');
this.$set(this.tab1Data.rows[index], 'imgUrl1', []);
},
async afterRead(file, index) {
let url = file.file.url;
const result = await this.uploadFilePromise(url);
let parsedResult = JSON.parse(result);
this.$set(this.anotherData.rows[index], 'imgUrl', [{ url }]);
this.$set(this.anotherData.rows[index], 'fileList', parsedResult.data);
},
deletePic(index) {
this.$set(this.anotherData.rows[index], 'fileList', '');
this.$set(this.anotherData.rows[index], 'imgUrl', []);
},
async afterRead1(file, index) {
let url = file.file.url;
const result = await this.uploadFilePromise(url);
let parsedResult = JSON.parse(result);
this.$set(this.anotherData.rows[index], 'imgUrl1', [{ url }]);
this.$set(this.anotherData.rows[index], 'fileList1', parsedResult.data);
},
deletePic1(index) {
this.$set(this.anotherData.rows[index], 'fileList1', '');
this.$set(this.anotherData.rows[index], 'imgUrl1', []);
},
async afterRead2(event) {
let lists = [].concat(event.file);
let fileListLen = this[`fileList${event.name}`].length;
lists.map((item) => {
this[`fileList${event.name}`].push({ ...item, status: 'uploading', message: '上传中' });
});
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url);
let parsedResult = JSON.parse(result);
let item = this[`fileList${event.name}`][fileListLen];
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, { status: 'success', message: '', url: parsedResult.data }));
fileListLen++;
}
console.log(this.fileList);
},
deletePic2(e) {
this['fileList'].splice(0, 1);
},
uploadFilePromise(url) {
const header = { 'Authorization': `Bearer ${getToken()}` };
return new Promise((resolve, reject) => {
let a = uni.uploadFile({
url: 'http://10.118.50.18:8001/api/danger_rectify_record/upload',
filePath: url,
header: header,
name: 'fileinput',
success: (res) => {
resolve(res.data);
}
});
});
},
fetchTab1Data() {
request({
url: '/api/check_carryout_record_daily/getPageData',
method: 'POST',
header: { 'content-type': 'application/json', 'Authorization': `Bearer ${getToken()}` },
data: {},
dataType: 'json'
}).then(response => {
this.tab1Data.originalRows = response.rows.map(item => ({
...item,
complianceStatus: '符合',
fileList: '',
imgUrl: [],
fileList1: '',
imgUrl1: []
}));
this.filterData(this.tab1Data);
this.tab1Areas = [...new Set(response.rows.map(item => item.AREA_NAME))];
}).catch(error => {
console.error(error);
uni.showToast({ title: '请求失败', icon: 'none' });
});
},
fetchTab2Data() {
request({
url: '/api/check_carryout_record/getPageData',
method: 'POST',
header: { 'content-type': 'application/json', 'Authorization': `Bearer ${getToken()}` },
dataType: 'json'
}).then(response => {
this.anotherData.originalRows = response.rows.map(item => ({
...item,
complianceStatus: '符合',
fileList: '',
imgUrl: [],
fileList1: '',
imgUrl1: []
}));
this.filterTab2Data(this.anotherData);
this.tab2Areas = [...new Set(response.rows.map(item => item.AREA_NAME))];
}).catch(error => {
console.error(error);
uni.showToast({ title: '请求失败', icon: 'none' });
});
},
showCheckStandardModal(checkSta) {
this.selectedItemForModal = { checkSta };
this.isAnotherModalVisible = true;
this.isModalVisible = false;
},
filterByArea() {
console.log('Selected Area:', this.selectedArea);
this.filterData(this.tab1Data);
this.filterTab2Data(this.anotherData);
},
filterData(data) {
const taskId = String(this.taskId);
data.rows = data.originalRows.filter(item => {
return String(item.Main_task_Nopri) === taskId && (!this.tab1SelectedArea || item.AREA_NAME === this.tab1SelectedArea);
});
},
filterTab2Data(data) {
const taskId = String(this.taskId);
data.rows = data.originalRows.filter(item => {
return String(item.Main_task_Nopri) === taskId && (!this.tab2SelectedArea || item.AREA_NAME === this.tab2SelectedArea);
});
},
showDetail(item) {
this.selectedItem = {
Main_task_Nopri: item.Main_task_Nopri,
DANGER_DESC: item.DANGER_DESC,
CHECK_AREA_ID: item.AREA_ID,
CHECK_AREA: item.AREA_NAME
};
this.isModalVisible = true;
},
closeModal() {
this.isModalVisible = false;
},
updateItem() {
if (this.fileList.length !== 0) {
this.selectedItem.DANGER_PIC = this.fileList[0].url;
}
let params = [];
for (const [key, value] of Object.entries(this.selectedItem)) {
params.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
}
const querystring = params.join('&');
const baseUrl = '/api/danger_rectify_record/InsertTaskDanger';
const urlWithParams = `${baseUrl}?${querystring}`;
request({
url: urlWithParams,
method: 'POST',
header: { 'content-type': 'application/json', 'Authorization': `Bearer ${getToken()}` },
dataType: 'json'
}).then(response => {
this.closeModal();
this.fetchTab1Data();
uni.showToast({ title: '更新成功', icon: 'success' });
}).catch(error => {
console.error(error);
uni.showToast({ title: '更新失败', icon: 'none' });
});
},
handleComplianceChange(event, item) {
const selectedIndex = event.detail.value;
const options = ['符合', '不符合'];
item.complianceStatus = options[selectedIndex];
},
submitAll() {
for (let i = 0; i < this.tab1Data.rows.length; i++) {
let mainData = {};
mainData.CHECK_C_ID = this.tab1Data.rows[i].CHECK_C_ID;
if (this.tab1Data.rows[i].fileList != '') {
mainData.CHECKPERSON_URL = this.tab1Data.rows[i].fileList;
}
if (this.tab1Data.rows[i].fileList1 != '') {
mainData.INSPECTOR_URLl = this.tab1Data.rows[i].fileList1;
}
const url = '/api/check_carryout_record_daily/checkstatus?CHECK_C_ID=' + mainData.CHECK_C_ID;
request({
url: url,
method: 'POST',
header: { 'content-type': 'application/json', 'Authorization': `Bearer ${getToken()}` },
data: { mainData },
dataType: 'json'
}).then(response => {
this.closeModal();
this.fetchTab1Data();
uni.showToast({ title: '更新成功', icon: 'success' });
}).catch(error => {
console.error(error);
uni.showToast({ title: '更新失败', icon: 'none' });
});
request({
url: '/api/check_carryout_record_daily/update',
method: 'POST',
header: { 'content-type': 'application/json', 'Authorization': `Bearer ${getToken()}` },
data: { mainData },
dataType: 'json'
}).then(response => {
this.closeModal();
this.fetchTab1Data();
uni.showToast({ title: '更新成功', icon: 'success' });
}).catch(error => {
console.error(error);
uni.showToast({ title: '更新失败', icon: 'none' });
});
}
},
submitAll1() {
for (let i = 0; i < this.anotherData.rows.length; i++) {
let mainData = {};
mainData.CHECK_C_ID = this.anotherData.rows[i].CHECK_C_ID;
if (this.anotherData.rows[i].fileList != '') {
mainData.CHECKPERSON_URL = this.anotherData.rows[i].fileList;
}
if (this.anotherData.rows[i].fileList1 != '') {
mainData.INSPECTOR_URLl = this.anotherData.rows[i].fileList1;
}
request({
url: '/api/check_carryout_record/update',
method: 'POST',
header: { 'content-type': 'application/json', 'Authorization': `Bearer ${getToken()}` },
data: { mainData },
dataType: 'json'
}).then(response => {
this.closeModal();
this.fetchTab1Data();
uni.showToast({ title: '更新成功', icon: 'success' });
}).catch(error => {
console.error(error);
uni.showToast({ title: '更新失败', icon: 'none' });
});
}
},
onLoad(options) {
if (options.id) {
this.taskId = decodeURIComponent(options.id);
}
if (options.checkType) {
this.checkType = decodeURIComponent(options.checkType);
}
this.setTabsVisibility();
this.fetchTab1Data();
this.fetchTab2Data();
},
setTabsVisibility() {
console.log('Setting tabs visibility with checkType:', this.checkType);
const checkType = parseInt(this.checkType);
switch (checkType) {
case 1:
case 8:
this.currentTab = 'tab1';
this.showTab2 = true;
console.log('showTab2 set to true');
break;
case 0:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 9:
this.currentTab = 'tab1';
this.showTab2 = false;
console.log('showTab2 set to false');
break;
default:
this.currentTab = 'tab1';
this.showTab2 = false;
console.log('showTab2 set to false (default)');
break;
}
},
onTab1PickerChange(e) {
const index = e.detail.value;
this.tab1SelectedIndex = index;
this.tab1SelectedArea = this.tab1Areas[index];
this.filterData(this.tab1Data);
},
onTab2PickerChange(e) {
const index = e.detail.value;
this.tab2SelectedIndex = index;
this.tab2SelectedArea = this.tab2Areas[index];
this.filterTab2Data(this.anotherData);
},
mounted() {
this.$nextTick(() => {
this.filterData(this.tab1Data);
this.filterTab2Data(this.anotherData);
});
},
// 新增的 handleAddFile 方法
handleAddFile() {
uni.navigateTo({
url: '/pages/SIGN/SIGN'
});
}
}
```
通过上述修改,当用户点击“点击进入签名”按钮时,将跳转到名为 `SIGN` 的页面。
阅读全文