| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- const _Http = getApp().globalData.http,
- getTime = require("../../utils/getTime");
- Page({
- data: {
- showAll: false,
- form: [{
- label: "项目",
- error: false,
- errMsg: "",
- type: "route",
- url: "/packageA/select/project/select",
- value: "",
- params: {
- id: 20221020143502,
- content: {
- nocache: true,
- "type": 0,
- "isExport": 0,
- "where": {
- "condition": "",
- }
- },
- },
- interrupt: true,
- query: "&radio=true",
- placeholder: "选择项目",
- valueName: "sa_projectid",
- checking: "base",
- required: true
- }, {
- label: "产品系列",
- error: false,
- errMsg: "",
- type: "option",
- optionNmae: "itemtype",
- optionType: "checkbox", //复选 radio 单选
- value: "",
- placeholder: "请选择产品系列",
- valueName: "itemtype",
- checking: "base",
- required: true
- }, {
- label: "折扣(%)",
- error: false,
- errMsg: "",
- hint: "请输入0-100整数!",
- type: "number",
- value: "",
- placeholder: "请填写折扣(%)",
- valueName: "discountrate", //绑定的字段名称
- required: false, //必填
- checking: `^([1-9]?\\d|100)$`, //0-100%
- slot: "discountrate"
- }, {
- label: "报价日期",
- error: false,
- errMsg: "",
- type: "date",
- value: getTime.formatTime(new Date(), '-').split(' ')[0],
- placeholder: "报价日期",
- valueName: "billdate",
- checking: "base",
- required: false
- }, {
- label: "有效期",
- error: false,
- errMsg: "",
- type: "dateRange",
- value: [getTime.formatTime(new Date(), '-').split(' ')[0], ""],
- placeholder: ['生效日期', '截止日期'],
- valueName: "invaliddate",
- checking: "base",
- required: true
- }, {
- label: "备注",
- error: false,
- errMsg: "",
- type: "textarea",
- value: "",
- placeholder: "报价单说明",
- valueName: "remarks",
- required: false, //必填
- }],
- disabled: true
- },
- onLoad(options) {
- if (options.data) {
- let data = JSON.parse(options.data);
- let form = this.data.form;
- if (data.sa_projectid) {
- form[0].value = data.sa_projectid;
- form.splice(1, 0, {
- label: "选择客户",
- error: false,
- errMsg: "",
- type: "route",
- url: "/packageA/select/setclient/select",
- value: "",
- params: {
- id: 20221027143702,
- "content": {
- nocache: true,
- "sa_projectid": data.sa_projectid[1][0],
- "where": {
- "condition": ""
- }
- },
- },
- query: "&radio=true&idname=sys_enterpriseid",
- placeholder: "选择客户",
- valueName: "sys_enterpriseid",
- checking: "base",
- required: true
- })
- };
- this.setData({
- disabled: false,
- form
- })
- }
- },
- /* 打断处理form */
- interrupt(e) {
- let {
- data,
- form,
- temporary
- } = e.detail;
- console.log("处理", data, form, temporary)
- if (temporary.item.value[0] == data.value[0]) return wx.navigateBack();
- let obj = {};
- temporary.item.value = data.value;
- switch (temporary.item.valueName) {
- case "sa_projectid":
- obj = {
- label: "选择客户",
- error: false,
- errMsg: "",
- type: "route",
- url: "/packageA/select/setclient/select",
- value: "",
- params: {
- id: 20221027143702,
- "content": {
- nocache: true,
- "sa_projectid": data.value[1][0],
- "where": {
- "condition": ""
- }
- },
- },
- interrupt: true,
- query: "&radio=true&idname=sys_enterpriseid",
- placeholder: "选择客户",
- valueName: "sys_enterpriseid",
- checking: "base",
- required: true
- };
- form.splice(1, form[1].label == "选择客户" ? 1 : 0, obj);
- this.setData({
- address: data.item.province + data.item.city + data.item.county + data.item.address
- })
- break;
- case "sys_enterpriseid":
- obj = {
- label: "联系人",
- error: false,
- errMsg: "",
- type: "route",
- url: "/packageA/select/contacts/select",
- value: "",
- params: {
- "id": "20221022165503",
- "content": {
- nocache: true,
- "sys_enterpriseid": data.value[1][0],
- pageNumber: 1,
- pageSize: 10,
- pageTotal: 1,
- "where": {
- "condition": "",
- "workaddress": 0
- }
- }
- },
- query: "&radio=true",
- placeholder: "选择客户联系人",
- valueName: "contactsid",
- checking: "base",
- required: false
- };
- form.splice(2, form[2].label == "联系人" ? 1 : 0, obj);
- break;
- }
- form[temporary.index] = temporary.item;
- wx.navigateBack()
- this.setData({
- form
- })
- },
- submit() {
- let content = {
- ...this.selectComponent("#Form").submit(),
- sa_quotedpriceid: 0
- };
- content.sys_enterpriseid = content.sys_enterpriseid[1] ? content.sys_enterpriseid[1][0] : 0;
- content.projectname = content.sa_projectid[0] || "";
- content.sa_projectid = content.sa_projectid[1] ? content.sa_projectid[1][0] : 0;
- content.contactsid = content.contactsid ? content.contactsid[1][0] : 0;
- content.discountrate = (content.discountrate / 100).toFixed(4) || 1;
- content.begdate = content.invaliddate[0];
- content.enddate = content.invaliddate[1];
- content.address = this.data.address;
- delete(content.invaliddate)
- _Http.basic({
- "id": 20221020164803,
- "version": 1,
- content
- }).then(res => {
- console.log("添加项目报价单", res)
- wx.showToast({
- title: res.msg != '成功' ? res.msg : '保存成功',
- icon: "none"
- })
- if (res.msg != '成功') return;
- setTimeout(() => {
- let pages = getCurrentPages(),
- page = pages[pages.length - 2];
- if (page.__route__ == 'packageA/offers/index') {
- page.getList(true);
- } else if (page.__route__ == 'packageA/project/detail') {
- let model = page.selectComponent("#Offers");
- model.getList(model.data.sa_projectid, true);
- }
- wx.redirectTo({
- url: '/packageA/offers/detail?sa_quotedpriceid=' + res.data.sa_quotedpriceid
- })
- }, 300)
- })
- },
- // 是否显示全部
- onChange({
- detail
- }) {
- this.setData({
- showAll: detail
- })
- },
- /* 表单必填项是否完成 */
- onConfirm({
- detail
- }) {
- this.setData({
- disabled: detail
- })
- }
- })
|