| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- import { sendMsgToMQ } from "../../../../services/api/common/index"
- import Toast from "../../../../miniprogram_npm/@vant/weapp/toast/toast";
- import { FunCode } from "../../../../constants/enum/funcode"
- import { accountid, isEncrypted, protoHeader, userid } from "../../../../services/utils";
- import services from "../../../../services/index"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- /// 履约单据信息
- order: <GuangZuan.MyPerformanc>({}),
- /// 备注信息
- remark: '',
- /// 文件上传列表
- fileList: [],
- /// 上传的文件路径
- filePath: ''
- },
- /// 照片上传
- afterRead(e: any) {
- const { file } = e.detail;
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
- wx.uploadFile({
- url: services.config.uploadUrl,
- filePath: file.url,
- name: 'file',
- formData: { user: 'test' },
- success: (res) => {
- if (res.statusCode != 200) {
- Toast({message: '图片上传失败,原因:'+res.errMsg})
- return
- }
- // 上传完成需要更新 fileList
- const { fileList = [] } = this.data;
- fileList.push({ ...file, url: res.data});
- this.setData({ fileList });
- /// 设置文件路径
- this.setData({ filePath: JSON.parse(res.data)[0].filePath })
- },
- });
- },
- /// 删除图片
- deleteImage(e: any) {
- const {index} = e.detail.index
- // 上传完成需要更新 fileList
- const { fileList = [] } = this.data;
- fileList.splice(index, 1)
- this.setData({ fileList });
- },
- /**
- * 违约申请
- */
- doBreach() {
- /// 校验失败
- if (!this.check()) { return }
- /// loding.....
- Toast.loading({ message: '违约申请请求中.....'})
- /// 参数信息
- const params = {
- PerformancePlanID: this.data.order.performanceplanid,
- BreachType: this.data.order.buyaccountid === accountid() ? 2 : 1,
- ApplyRemark: this.data.remark,
- Applicant: userid(),
- Header: protoHeader(FunCode.PerformanceContractedApplyReq)
- }
- /// 发送请求
- sendMsgToMQ({
- data: {
- data: JSON.stringify(params),
- funCodeReq: FunCode.PerformanceContractedApplyReq,
- funCodeRsp: FunCode.PerformanceContractedApplyRsp,
- isEncrypted: isEncrypted()
- },
- success: (res) => {
- if (res.code != 0) {
- Toast.fail({message: '操作申请失败, 原因:'+res.msg})
- return
- }
- /// 操作成功
- Toast.success('操作成功')
- /// 返回上层视图
- wx.navigateBack()
- },
- fail: (emsg) => {
- /// 操作失败
- Toast.fail('操作失败,原因:'+emsg)
- }, complete: () => {
- /// hideLoading
- Toast.clear()
- }
- })
- },
- check(): boolean {
- if (this.data.remark === '') {
- Toast.fail({message: '请输入备注!'})
- return false
- }
- if (this.data.filePath === '') {
- Toast.fail({message: '请上传附件!'})
- return false
- }
- return true
- },
- /**
- * 返回上层视图
- */
- backToParent() {
- /// 返回上层视图
- wx.navigateBack()
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options: any) {
- const myPerformanc: GuangZuan.MyPerformanc = JSON.parse(options.id ?? '')
- if (myPerformanc) {
- this.setData({
- order: myPerformanc
- })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|