change.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. let _Http = getApp().globalData.http,
  2. count = null;
  3. Page({
  4. data: {
  5. showAll: false,
  6. form: [{
  7. label: "项目名称",
  8. error: false,
  9. errMsg: "",
  10. type: "textarea",
  11. value: "",
  12. placeholder: "项目名称",
  13. valueName: "projectname",
  14. checking: "base",
  15. required: true,
  16. interrupt: true,
  17. permit: true, //无视errMsg 运行提交
  18. }, {
  19. label: "项目类型",
  20. error: false,
  21. errMsg: "",
  22. type: "option",
  23. optionNmae: "projecttype",
  24. optionType: "radio", //复选 radio 单选
  25. value: "",
  26. placeholder: "选择类型",
  27. valueName: "projecttype",
  28. checking: "base",
  29. required: true
  30. }, {
  31. label: "项目方阶段",
  32. error: false,
  33. errMsg: "",
  34. type: "option",
  35. optionNmae: "squarestage",
  36. optionType: "radio", //复选 radio 单选
  37. value: "",
  38. placeholder: "选择项目方阶段",
  39. valueName: "squarestage",
  40. checking: "base",
  41. required: false
  42. }, {
  43. label: "项目等级",
  44. error: false,
  45. errMsg: "",
  46. type: "option",
  47. optionNmae: "projectgrade",
  48. optionType: "radio", //复选 radio 单选
  49. value: "",
  50. placeholder: "选择项目等级",
  51. valueName: "grade",
  52. checking: "base",
  53. required: false
  54. }, {
  55. label: "省市县",
  56. error: false,
  57. errMsg: "",
  58. type: "region",
  59. value: [],
  60. placeholder: "省/市/县",
  61. valueName: "region",
  62. required: true
  63. }, {
  64. label: "详细地址",
  65. error: false,
  66. errMsg: "",
  67. type: "textarea",
  68. value: "",
  69. placeholder: "详细地址",
  70. valueName: "address",
  71. checking: "base",
  72. required: false
  73. }, {
  74. label: "项目规模",
  75. error: false,
  76. errMsg: "",
  77. type: "digit",
  78. value: "",
  79. placeholder: "请填写数值",
  80. valueName: "scale",
  81. checking: "base",
  82. required: false
  83. }, {
  84. label: "项目规模单位",
  85. error: false,
  86. errMsg: "",
  87. type: "option",
  88. optionNmae: "scaleunitname",
  89. optionType: "radio", //复选 radio 单选
  90. value: "",
  91. placeholder: "选择单位",
  92. valueName: "unitname",
  93. required: false
  94. }, {
  95. label: "项目预算(万元)",
  96. error: false,
  97. errMsg: "",
  98. type: "digit",
  99. value: "",
  100. placeholder: "请填写金额",
  101. valueName: "budgetary",
  102. checking: "base",
  103. required: false
  104. }, {
  105. label: "总投资额(万元)",
  106. error: false,
  107. errMsg: "",
  108. type: "digit",
  109. value: "",
  110. placeholder: "请填写金额",
  111. valueName: "totalinvestment",
  112. checking: "base",
  113. required: false
  114. }, {
  115. label: "造价(万元)",
  116. error: false,
  117. errMsg: "",
  118. type: "digit",
  119. value: "",
  120. placeholder: "请填写金额",
  121. valueName: "costofconstruction",
  122. checking: "base",
  123. required: false
  124. }, {
  125. label: "预计开工时间",
  126. error: false,
  127. errMsg: "",
  128. type: "date",
  129. fields: "month",
  130. value: "",
  131. placeholder: "预计开工时间",
  132. valueName: "begdate_due",
  133. checking: "base",
  134. required: false
  135. }, {
  136. label: "预计完工时间",
  137. error: false,
  138. errMsg: "",
  139. type: "date",
  140. fields: "month",
  141. value: "",
  142. placeholder: "预计完工时间",
  143. valueName: "enddate_due",
  144. checking: "base",
  145. required: false
  146. },
  147. {
  148. label: "预计签约时间",
  149. error: false,
  150. errMsg: "",
  151. type: "date",
  152. fields: "month",
  153. value: "",
  154. placeholder: "预计签约时间",
  155. valueName: "signdate_due",
  156. checking: "base",
  157. required: false
  158. }, {
  159. label: "领域",
  160. error: false,
  161. errMsg: "",
  162. type: "selector",
  163. range: [],
  164. rangeKey: "name",
  165. selectKey: "tradefield",
  166. rangeIndex: "",
  167. value: "",
  168. placeholder: "领域",
  169. valueName: "tradefield",
  170. required: true, //必填
  171. }, {
  172. label: "品牌",
  173. error: false,
  174. errMsg: "",
  175. type: "route",
  176. url: "/packageA/select/brand/select",
  177. params: {
  178. "id": 20220924163702,
  179. "content": {
  180. nochace: true,
  181. }
  182. },
  183. query: "&radio=true",
  184. value: "",
  185. placeholder: "选择品牌",
  186. valueName: "sa_brandid",
  187. checking: "base",
  188. required: false
  189. }, {
  190. label: "品牌是否由提报方植入",
  191. error: false,
  192. errMsg: "",
  193. hint: "",
  194. type: "radio",
  195. value: "",
  196. radioList: [{
  197. id: '1',
  198. name: '是'
  199. }, {
  200. id: '0',
  201. name: '否'
  202. }],
  203. valueName: "isfillbrangd", //绑定的字段名称
  204. required: false, //必填
  205. }
  206. ],
  207. "content": {
  208. "sat_orderclueid": ""
  209. },
  210. disabled: true
  211. },
  212. onLoad(options) {
  213. getApp().globalData.Language.getLanguagePackage(this, '转化项目');
  214. if (wx.getStorageSync('userMsg').siteid == 'HY') this.setHY();
  215. let data = JSON.parse(options.rowData);
  216. data.sa_brandid = ""
  217. this.setData({
  218. form: this.data.form.map(v => {
  219. if (v.valueName != 'region') {
  220. if (v.valueName == 'campaign_name') {
  221. v.value = [data[v.valueName],
  222. [data.sat_campaignid]
  223. ]
  224. } else {
  225. v.value = data[v.valueName];
  226. }
  227. } else {
  228. v.value = data.province ? [data.province, data.city, data.county] : []
  229. }
  230. return v
  231. }),
  232. 'content.sat_orderclueid': data.sat_orderclueid,
  233. 'content.sat_campaignid': data.sat_campaignid
  234. });
  235. /* 获取领域 */
  236. _Http.basic({
  237. "id": 20221223141802,
  238. "content": {
  239. "pageNumber": 1,
  240. "pageSize": 99999,
  241. "where": {
  242. "condition": ""
  243. }
  244. }
  245. }).then(res => {
  246. console.log("获取领域", res)
  247. let item = this.data.form.find(v => v.label == '领域');
  248. item.range = res.code == '1' ? res.data.map(v => {
  249. v.name = getApp().globalData.Language.getMapText(v.tradefield)
  250. return v
  251. }) : [];
  252. this.setData({
  253. form: this.data.form
  254. })
  255. })
  256. },
  257. async interrupt(e) {
  258. let {
  259. data,
  260. form,
  261. temporary
  262. } = e.detail;
  263. if (data.label == "项目名称") {
  264. if (data.value) {
  265. const result = await this.selectComponent("#projectname").queryList(data.value);
  266. if (typeof result == 'string') {
  267. data.errMsg = result;
  268. form[0] = data;
  269. this.setData({
  270. form
  271. })
  272. } else {
  273. if (result) {
  274. data.errMsg = '疑似重复';
  275. form[0] = data;
  276. this.setData({
  277. form
  278. })
  279. } else {
  280. if (data.errMsg) {
  281. data.errMsg = '';
  282. form[0] = data;
  283. this.setData({
  284. form
  285. })
  286. }
  287. }
  288. }
  289. } else {
  290. if (data.errMsg) {
  291. data.errMsg = '';
  292. form[0] = data;
  293. this.setData({
  294. form
  295. })
  296. }
  297. }
  298. }
  299. },
  300. setHY() {
  301. let required = ["预计签约时间", "项目等级", "详细地址", "项目规模"],
  302. remove = ["项目预算(万元)", "总投资额(万元)", "造价(万元)"];
  303. this.setData({
  304. form: this.data.form.filter(v => !remove.includes(v.label)).map(v => {
  305. if (required.includes(v.label)) v.required = true;
  306. // if (v.valueName == 'projectname') v.interrupt = false;
  307. return v
  308. }),
  309. siteid: wx.getStorageSync('userMsg').siteid,
  310. })
  311. },
  312. /* 查询是否重复 */
  313. async queryRepetition(e) {
  314. let data = this.selectComponent("#Form").query();
  315. /* if (data.projectname == '') return wx.showToast({
  316. title: `您还未填写项目名称`,
  317. icon: "none"
  318. }); */
  319. data.province = data.region[0] || "";
  320. data.city = data.region[1] || "";
  321. data.county = data.region[2] || "";
  322. let res = await this.handleQueryRepetition({
  323. sa_projectid: this.data.sa_projectid,
  324. ...data
  325. });
  326. console.log("查询重复", res)
  327. if (res.code != '1') return wx.showToast({
  328. title: res.msg,
  329. icon: "none"
  330. });
  331. this.setData({
  332. countDown: 6
  333. });
  334. count = setInterval(() => {
  335. let countDown = this.data.countDown;
  336. if (countDown == 0) {
  337. clearInterval(count);
  338. this.setData({
  339. countDown: ""
  340. })
  341. } else {
  342. countDown--;
  343. this.setData({
  344. countDown
  345. })
  346. }
  347. }, 1000)
  348. if (res.total == 0) {
  349. getApp().globalData.Language.showToast('未查询到疑似重复的项目信息')
  350. this.data.repetitionShow = false;
  351. } else {
  352. wx.showToast({
  353. title: getApp().globalData.Language.getMapText('查询到') + res.total + getApp().globalData.Language.getMapText('条疑似重复项目信息'),
  354. icon: "none"
  355. })
  356. this.setData({
  357. repetitionShow: true,
  358. repetitionList: res.data.map(v => {
  359. v.chars = v.chars.reduce((acc, item) => ({
  360. ...acc,
  361. ...item
  362. }), {});
  363. v.projectname = v.projectname.split('').map(text => {
  364. let projectname = v.chars.projectname.join("") || ''
  365. return projectname.includes(text) ? {
  366. text,
  367. color: "red"
  368. } : {
  369. text,
  370. color: "#666666"
  371. }
  372. })
  373. return v
  374. }),
  375. })
  376. }
  377. },
  378. repClose() {
  379. if (this.data.isSubmit) {
  380. let that = this;
  381. wx.showModal({
  382. title: getApp().globalData.Language.getMapText('提示'),
  383. content: getApp().globalData.Language.getMapText('是否继续创建项目'),
  384. cancelText: getApp().globalData.Language.getMapText('取消'),
  385. confirmText: getApp().globalData.Language.getMapText('创建'),
  386. complete: (res) => {
  387. if (res.confirm) that.handleSubmit(true);
  388. }
  389. })
  390. }
  391. this.setData({
  392. repetitionShow: false,
  393. isSubmit: false
  394. })
  395. },
  396. /* 处理查重 */
  397. handleQueryRepetition(content) {
  398. return _Http.basic({
  399. "id": 20221208184202,
  400. content
  401. })
  402. },
  403. async submit() {
  404. let data = this.selectComponent("#Form").submit(),
  405. that = this;
  406. data.province = data.region[0] || "";
  407. data.city = data.region[1] || "";
  408. data.county = data.region[2] || "";
  409. let query = await this.handleQueryRepetition({
  410. sa_projectid: this.data.sa_projectid,
  411. ...data
  412. });
  413. if (query.code == 0) return wx.showModal({
  414. content: query.msg,
  415. confirmText: getApp().globalData.Language.getMapText('关闭'),
  416. showCancel: false
  417. })
  418. if (query.total != 0) {
  419. if (this.data.siteid == 'HY') {
  420. wx.showModal({
  421. title: getApp().globalData.Language.getMapText('提示'),
  422. content: getApp().globalData.Language.getMapText('查询到') + query.total + getApp().globalData.Language.getMapText('条疑似重复项目信息,是否确定继续创建项目'),
  423. cancelText: getApp().globalData.Language.getMapText('取消'),
  424. confirmText: getApp().globalData.Language.getMapText('创建'),
  425. complete: (res) => {
  426. if (res.confirm) that.handleSubmit(true);
  427. }
  428. })
  429. } else {
  430. wx.showToast({
  431. title: getApp().globalData.Language.getMapText('查询到') + query.total + getApp().globalData.Language.getMapText('条疑似重复项目信息'),
  432. icon: "none"
  433. })
  434. this.setData({
  435. repetitionShow: true,
  436. repetitionList: res.data.map(v => {
  437. v.chars = v.chars.reduce((acc, item) => ({
  438. ...acc,
  439. ...item
  440. }), {});
  441. v.projectname = v.projectname.split('').map(text => {
  442. let projectname = v.chars.projectname.join("") || ''
  443. return projectname.includes(text) ? {
  444. text,
  445. color: "red"
  446. } : {
  447. text,
  448. color: "#666666"
  449. }
  450. })
  451. return v
  452. }),
  453. isSubmit: true
  454. })
  455. }
  456. } else {
  457. this.handleSubmit();
  458. }
  459. },
  460. handleSubmit(tag = false) {
  461. this.setData({
  462. loading: true
  463. })
  464. let data = {
  465. ...this.data.content,
  466. ...this.selectComponent("#Form").submit()
  467. };
  468. data.province = data.region[0] || "";
  469. data.city = data.region[1] || "";
  470. data.county = data.region[2] || "";
  471. data.tradefields = [data.tradefields];
  472. data.sa_brandid = data.sa_brandid ? data.sa_brandid[1][0] : 0;
  473. if (data.scale.length != 0 && data.scale == 0) {
  474. this.setData({
  475. loading: false
  476. })
  477. getApp().globalData.Language.showToast('项目规模不可为0')
  478. return;
  479. }
  480. if (data.unitname == "") {
  481. this.setData({
  482. loading: false
  483. })
  484. getApp().globalData.Language.showToast('还未选择项目规模单位')
  485. return;
  486. }
  487. delete(data.region);
  488. _Http.basic({
  489. "id": 20221124154902,
  490. content: data
  491. }).then(res => {
  492. this.setData({
  493. loading: false
  494. })
  495. console.log("转化", res)
  496. wx.showToast({
  497. title: res.code != '1' ? res.msg : getApp().globalData.Language.getMapText(wx.getStorageSync('userMsg').siteid != 'HY' ? '提交成功' : '转化成功'),
  498. icon: "none"
  499. })
  500. if (res.code != '1') return;
  501. //绑定疑似重复标签
  502. if (tag) _Http.basic({
  503. "id": 20220929090901,
  504. "content": {
  505. "ownertable": "sa_project",
  506. "ownerid": res.data.sa_projectid,
  507. "datatag": ["疑似重复"]
  508. }
  509. })
  510. setTimeout(() => {
  511. getCurrentPages().forEach(v => {
  512. if (v.__route__ == 'packageA/saleClue/detail') v.getDetail()
  513. })
  514. wx.navigateBack()
  515. if (wx.getStorageSync('userMsg').siteid != 'HY') {
  516. wx.navigateTo({
  517. url: `/packageA/project/detail?id=${res.data.sa_projectid}`,
  518. })
  519. }
  520. }, 300)
  521. })
  522. },
  523. // 是否显示全部
  524. onChange({
  525. detail
  526. }) {
  527. this.setData({
  528. showAll: detail
  529. })
  530. },
  531. /* 表单必填项是否完成 */
  532. onConfirm({
  533. detail
  534. }) {
  535. this.setData({
  536. disabled: detail
  537. })
  538. }
  539. })