123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- var util = require('../../../utils/util.js')
- const app = getApp();
- Page({
- data: {
- allDisabled:true,//有客户下拉时临时用来控制其他下拉不显示
- c_txt_Show:false,
- customerShow:false,
-
-
- //款项状态
- moneyStatusList: [
- { "name": "需要收款", "id": "需要收款" },
- { "name": "无需收款", "id": "无需收款" },
- ],
- moneyIndex: 0,
- moneyId:'需要收款',
-
- isCost: true,
-
-
- id:"",
-
-
- rules: {
- costStatus: [{ required: true, message: '款项状态必填', trigger: 'blur' }],
- serviceCost: [{ required: true, message: '服务费用必填', trigger: 'blur' }],
- },
- // 新增/编辑
- create: {
- dialogStatus: '',
- temp: {
- costStatus: '需要收款',
- serviceCost: '',
- payDate: '',
- remoteSummary: '',
- created: util.getToday(),
- id:"",
- receiverChoose: 'true'
- },
-
- }
- },
- onLoad: function (options) {
- // 表单初始化
- wx.lin.initValidateForm(this)
-
- var id = options.id;
- this.setData({
- id:id,
- ['create.temp.id']:id
- })
-
- //被投诉人
- //util.getDataByName({name: 'getEmployeesSelect',parammaps: {}}, this.getPickerList3)
- },
-
- getPickerList3: function (res) {
- console.log('被投诉人下拉数据======>', res.data.list)
- this.setData({
- moneyStatusList: res.data.list
- })
- },
-
- //日期选择触发
- on_payDate_tap:function(e){
- this.setData({
- ['create.temp.payDate']:e.detail.value
- })
- },
-
-
- //下拉框:款项状态
- change_costStatus:function(e){
- console.log('change_costStatus的选项', e.detail.value)
- var newId = this.data.moneyStatusList[e.detail.value]['id']
- console.log('change_costStatus的newId', newId)
-
- this.setData({
- moneyIndex: e.detail.value,
- moneyId: newId,
- ['create.temp.costStatus']: newId,
- })
- if(newId == '需要收款'){
- this.setData({
- isCost: true,
- })
- } else {
- this.setData({
- isCost: false,
- })
- }
-
- },
-
-
-
-
- //保存
- submit:function(e){
-
- var detail_value = e.detail.values
- var detail_errors = e.detail.errors
- var detail_errors = e.detail.errors
- console.log("detail_value",detail_value)
- console.log("create.temp",this.data.create.temp)
-
- const submit_data = Object.assign({}, this.data.create.temp, detail_value)
-
- console.log("保存发送:",submit_data)
-
-
- var send_data = {
- "name":"completeService",
- "parammaps":{
- "costStatus":submit_data.costStatus,
- "serviceCost":submit_data.serviceCost,
- "payDate":submit_data.payDate,
- "remoteSummary":submit_data.remoteSummary,
- "id":this.data.id
- }
- }
- console.log("send_data",JSON.stringify(send_data))
-
- if(submit_data.costStatus == '需要收款'){
- if(submit_data.serviceCost == ""){
- wx.showToast({title: '服务费用必填',icon: 'none',duration: 2000})
- return false
- }
- }
- //验证必填项是否为空
- if(submit_data.costStatus == ""){
- wx.showToast({title: '款项状态必填',icon: 'none',duration: 2000})
- } else {
- if( wx.getStorageSync('isLoading') == "true"){
- wx.showToast({
- title: '正在保存中,请稍等!',
- icon: 'none',
- duration: 2000
- })
- } else {
- util.postDataByName(send_data, this.getListSuccess)
- }
- }
- },
- getListSuccess: function (res) {
- console.log('table数据======>', res)
- if (res.msg !== 'fail') {
- wx.showToast({
- title: '保存成功',
- icon: 'success',
- duration: 2000,
- success: function(){
- setTimeout(() => {
- wx.redirectTo({ url:"../siteService/siteService"})
- }, 1500)
- }
- })
- } else {
- wx.showToast({
- title: '保存失败'+res.data,
- icon: 'error',
- duration: 2000,
- })
- }
- },
-
-
- onReady: function () {
- },
-
- onShow: function () {
- },
-
- onHide: function () {
- },
-
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
-
- onShareAppMessage: function () {
- }
- })
|