| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- let _Http = getApp().globalData.http,
- count = null;
- Page({
- data: {
- loading: false,
- repetitionShow: false,
- repetitionList: [],
- isSubmit: false,
- sa_projectid: 0,
- showAll: false,
- disabled: true,
- form: [{
- label: "项目名称",
- error: false,
- errMsg: "",
- type: "textarea",
- value: "",
- placeholder: "项目名称",
- valueName: "projectname",
- checking: "base",
- required: true
- }, {
- label: "项目类型",
- error: false,
- errMsg: "",
- type: "option",
- optionNmae: "projecttype",
- optionType: "radio", //复选 radio 单选
- value: "",
- placeholder: "选择类型",
- valueName: "projecttype",
- checking: "base",
- required: true
- }, {
- label: "项目等级",
- error: false,
- errMsg: "",
- type: "option",
- optionNmae: "projectgrade",
- optionType: "radio", //复选 radio 单选
- value: "",
- placeholder: "选择项目等级",
- valueName: "grade",
- checking: "base",
- required: false
- }, {
- label: "省市县",
- error: false,
- errMsg: "",
- type: "region",
- value: [],
- placeholder: "省/市/县",
- valueName: "region",
- required: true
- }, {
- label: "详细地址",
- error: false,
- errMsg: "",
- type: "textarea",
- value: "",
- placeholder: "详细地址",
- valueName: "address",
- checking: "base",
- required: false
- }, {
- label: "项目规模",
- error: false,
- errMsg: "",
- type: "digit",
- value: "",
- placeholder: "请填写数值",
- valueName: "scale",
- checking: "base",
- required: false
- }, {
- label: "项目规模单位",
- error: false,
- errMsg: "",
- type: "option",
- optionNmae: "scaleunitname",
- optionType: "radio", //复选 radio 单选
- value: "",
- placeholder: "选择单位",
- valueName: "unitname",
- required: false
- }, {
- label: "项目预算(万元)",
- error: false,
- errMsg: "",
- type: "digit",
- value: "",
- placeholder: "请填写金额",
- valueName: "budgetary",
- checking: "base",
- required: false
- }, {
- label: "总投资额(万元)",
- error: false,
- errMsg: "",
- type: "digit",
- value: "",
- placeholder: "请填写金额",
- valueName: "totalinvestment",
- checking: "base",
- required: false
- }, {
- label: "造价(万元)",
- error: false,
- errMsg: "",
- type: "digit",
- value: "",
- placeholder: "请填写金额",
- valueName: "costofconstruction",
- checking: "base",
- required: false
- }, {
- label: "预计开工时间",
- error: false,
- errMsg: "",
- type: "date",
- fields: "month",
- value: "",
- placeholder: "预计开工时间",
- valueName: "begdate_due",
- checking: "base",
- required: false
- }, {
- label: "预计完工时间",
- error: false,
- errMsg: "",
- type: "date",
- fields: "month",
- value: "",
- placeholder: "预计完工时间",
- valueName: "enddate_due",
- checking: "base",
- required: false
- },
- {
- label: "预计签约时间",
- error: false,
- errMsg: "",
- type: "date",
- fields: "month",
- value: "",
- placeholder: "预计签约时间",
- valueName: "signdate_due",
- checking: "base",
- required: false
- }, {
- label: "领域",
- error: false,
- errMsg: "",
- type: "option",
- optionNmae: "tradefield",
- optionType: "radio", //复选 radio 单选
- value: "",
- placeholder: "选择领域",
- valueName: "tradefields",
- checking: "base",
- required: true
- }, {
- label: "品牌",
- error: false,
- errMsg: "",
- type: "route",
- url: "/packageA/select/brand/select",
- params: {
- "id": 20220924163702,
- "content": {
- nochace: true,
- }
- },
- query: "&radio=true",
- value: "",
- placeholder: "选择品牌",
- valueName: "sa_brandid",
- checking: "base",
- required: false
- }
- ],
- countDown: "", //查重倒计时
- },
- onLoad(options) {
- if (options.data) {
- let data = JSON.parse(options.data);
- let disabled = options.disabled == "true";
- data.sa_brandid = [data.brandname, [data.sa_brandid]]
- this.setData({
- disabled: false,
- sa_projectid: data.sa_projectid,
- form: this.data.form.map(v => {
- if (v.valueName != 'region') {
- v.value = data[v.valueName];
- } else {
- v.value = data.province ? [data.province, data.city, data.county] : []
- };
- if (disabled) {
- if (['projectname', 'region', 'address'].includes(v.valueName)) v.disabled = true
- }
- return v
- })
- });
- } else {
- //查询默认项目规模单位
- this.getUnitname();
- }
- },
- getUnitname() {
- _Http.basic({
- "classname": "sysmanage.develop.optiontype.optiontype",
- "method": "optiontypeselect",
- "content": {
- pageNumber: 1,
- "pageSize": 1,
- "typename": "scaleunitname",
- "parameter": {
- "siteid": wx.getStorageSync('siteP').siteid
- }
- }
- }).then(res => {
- console.log("项目规模", res)
- if (res.msg == '成功') {
- let index = this.data.form.findIndex(v => v.label == '项目规模单位');
- if (index != -1) this.setData({
- [`form[${index}].value`]: res.data[0].value
- })
- }
- })
- },
- /* 表单必填项是否完成 */
- onConfirm({
- detail
- }) {
- this.setData({
- disabled: detail
- })
- },
- // 是否显示全部
- onChange({
- detail
- }) {
- this.setData({
- showAll: detail
- })
- },
- /* 查询是否重复 */
- async queryRepetition(e) {
- let data = this.selectComponent("#Form").query();
- /* if (data.projectname == '') return wx.showToast({
- title: `您还未填写项目名称`,
- icon: "none"
- }); */
- data.province = data.region[0] || "";
- data.city = data.region[1] || "";
- data.county = data.region[2] || "";
- let res = await this.handleQueryRepetition({
- sa_projectid: this.data.sa_projectid,
- ...data
- });
- console.log("查询重复", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- this.setData({
- countDown: 6
- });
- count = setInterval(() => {
- let countDown = this.data.countDown;
- if (countDown == 0) {
- clearInterval(count);
- this.setData({
- countDown: ""
- })
- } else {
- countDown--;
- this.setData({
- countDown
- })
- }
- }, 1000)
- if (res.total == 0) {
- wx.showToast({
- title: '未查询到疑似重复的项目信息',
- icon: "none"
- })
- } else {
- wx.showToast({
- title: `查询到${res.total}条疑似重复项目信息`,
- icon: "none"
- })
- this.setData({
- repetitionShow: true,
- repetitionList: res.data
- })
- }
- },
- repClose() {
- if (this.data.isSubmit) {
- let that = this;
- wx.showModal({
- title: '提示',
- content: `是否继续创建项目`,
- complete: (res) => {
- if (res.confirm) that.handleSubmit(true);
- }
- })
- }
- this.setData({
- repetitionShow: false,
- isSubmit: false
- })
- },
- /* 处理查重 */
- handleQueryRepetition(content) {
- return _Http.basic({
- "id": 20221208184202,
- content
- })
- },
- async submit() {
- let data = this.selectComponent("#Form").submit();
- data.province = data.region[0] || "";
- data.city = data.region[1] || "";
- data.county = data.region[2] || "";
- let query = await this.handleQueryRepetition({
- sa_projectid: this.data.sa_projectid,
- ...data
- });
- if (query.total != 0) {
- wx.showToast({
- title: `查询到${query.total}条疑似重复项目信息`,
- icon: "none"
- })
- this.setData({
- repetitionShow: true,
- repetitionList: query.data,
- isSubmit: true
- })
- } else {
- this.handleSubmit();
- }
- },
- handleSubmit(tag = false) {
- this.setData({
- loading: true
- })
- let data = this.selectComponent("#Form").submit();
- data.province = data.region[0] || "";
- data.city = data.region[1] || "";
- data.county = data.region[2] || "";
- data.tradefields = [data.tradefields];
- data.sa_brandid = data.sa_brandid ? data.sa_brandid[1][0] : 0;
- delete(data.region);
- _Http.basic({
- "id": 20221020144202,
- "content": {
- sa_projectid: this.data.sa_projectid,
- ...data
- }
- }).then(res => {
- this.setData({
- loading: false
- })
- console.log("新建项目", res)
- wx.showToast({
- title: res.msg != '成功' ? res.msg : "保存成功",
- icon: "none",
- mask: true
- })
- if (res.msg != '成功') return;
- //绑定疑似重复标签
- if (tag) _Http.basic({
- "id": 20220929090901,
- "content": {
- "ownertable": "sa_project",
- "ownerid": res.data.sa_projectid,
- "datatag": ["疑似重复"]
- }
- })
- setTimeout(() => {
- let page = getCurrentPages()[getCurrentPages().length - 2];
- if (page.__route__ == 'packageA/project/index') {
- wx.redirectTo({
- url: '/packageA/project/detail?id=' + res.data.sa_projectid,
- })
- } else if (page.__route__ == 'packageA/project/detail') {
- wx.navigateBack()
- page.getDetail();
- }
- }, 500)
- })
- }
- })
|