addProjectOffer.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. const _Http = getApp().globalData.http,
  2. getTime = require("../../utils/getTime");
  3. Page({
  4. data: {
  5. showAll: false,
  6. form: [{
  7. label: "项目",
  8. error: false,
  9. errMsg: "",
  10. type: "route",
  11. url: "/packageA/select/project/select",
  12. value: "",
  13. params: {
  14. id: 20221020143502,
  15. content: {
  16. nocache: true,
  17. "type": 0,
  18. "isExport": 0,
  19. "where": {
  20. "condition": "",
  21. }
  22. },
  23. },
  24. interrupt: true,
  25. query: "&radio=true",
  26. placeholder: "选择项目",
  27. valueName: "sa_projectid",
  28. checking: "base",
  29. required: true
  30. }, {
  31. label: "产品系列",
  32. error: false,
  33. errMsg: "",
  34. type: "option",
  35. optionNmae: "itemtype",
  36. optionType: "checkbox", //复选 radio 单选
  37. value: "",
  38. placeholder: "请选择产品系列",
  39. valueName: "itemtype",
  40. checking: "base",
  41. required: true
  42. }, /* {
  43. label: "电话",
  44. error: false,
  45. errMsg: "",
  46. type: "number",
  47. value: "",
  48. valueName: "telephone",
  49. placeholder: "固定电话 例:0573-12345678",
  50. checking: "base",
  51. required: false
  52. }, */ {
  53. label: "报价日期",
  54. error: false,
  55. errMsg: "",
  56. type: "date",
  57. value: getTime.formatTime(new Date(), '-').split(' ')[0],
  58. placeholder: "报价日期",
  59. valueName: "billdate",
  60. checking: "base",
  61. required: false
  62. }, {
  63. label: "有效期",
  64. error: false,
  65. errMsg: "",
  66. type: "dateRange",
  67. value: [getTime.formatTime(new Date(), '-').split(' ')[0], ""],
  68. placeholder: ['生效日期', '截止日期'],
  69. valueName: "invaliddate",
  70. checking: "base",
  71. required: true
  72. }, {
  73. label: "备注",
  74. error: false,
  75. errMsg: "",
  76. type: "textarea",
  77. value: "",
  78. placeholder: "报价单说明",
  79. valueName: "remarks",
  80. required: false, //必填
  81. }],
  82. disabled: true
  83. },
  84. onLoad(options) {
  85. if (options.data) {
  86. let data = JSON.parse(options.data);
  87. let form = this.data.form;
  88. if (data.sa_projectid) {
  89. form[0].value = data.sa_projectid;
  90. form.splice(1, 0, {
  91. label: "选择客户",
  92. error: false,
  93. errMsg: "",
  94. type: "route",
  95. url: "/packageA/select/setclient/select",
  96. value: "",
  97. params: {
  98. id: 20221027143702,
  99. "content": {
  100. nocache: true,
  101. "sa_projectid": data.sa_projectid[1][0],
  102. "where": {
  103. "condition": ""
  104. }
  105. },
  106. },
  107. query: "&radio=true&idname=sys_enterpriseid",
  108. placeholder: "选择客户",
  109. valueName: "sys_enterpriseid",
  110. checking: "base",
  111. required: true
  112. })
  113. };
  114. this.setData({
  115. disabled: false,
  116. form
  117. })
  118. }
  119. },
  120. /* 打断处理form */
  121. interrupt(e) {
  122. let {
  123. data,
  124. form,
  125. temporary
  126. } = e.detail;
  127. console.log("处理", data, form, temporary)
  128. if (temporary.item.value[0] == data.value[0]) return wx.navigateBack();
  129. let obj = {};
  130. temporary.item.value = data.value;
  131. switch (temporary.item.valueName) {
  132. case "sa_projectid":
  133. obj = {
  134. label: "选择客户",
  135. error: false,
  136. errMsg: "",
  137. type: "route",
  138. url: "/packageA/select/setclient/select",
  139. value: "",
  140. params: {
  141. id: 20221027143702,
  142. "content": {
  143. nocache: true,
  144. "sa_projectid": data.value[1][0],
  145. "where": {
  146. "condition": ""
  147. }
  148. },
  149. },
  150. interrupt: true,
  151. query: "&radio=true&idname=sys_enterpriseid",
  152. placeholder: "选择客户",
  153. valueName: "sys_enterpriseid",
  154. checking: "base",
  155. required: true
  156. };
  157. form.splice(1, form[1].label == "选择客户" ? 1 : 0, obj);
  158. break;
  159. case "sys_enterpriseid":
  160. obj = {
  161. label: "联系人",
  162. error: false,
  163. errMsg: "",
  164. type: "route",
  165. url: "/packageA/select/contacts/select",
  166. value: "",
  167. params: {
  168. "id": "20221022165503",
  169. "content": {
  170. nocache: true,
  171. "sys_enterpriseid": data.value[1][0],
  172. pageNumber: 1,
  173. pageSize: 10,
  174. pageTotal: 1,
  175. "where": {
  176. "condition": "",
  177. "workaddress": 0
  178. }
  179. }
  180. },
  181. query: "&radio=true",
  182. placeholder: "选择客户联系人",
  183. valueName: "contactsid",
  184. checking: "base",
  185. required: false
  186. };
  187. form.splice(2, form[2].label == "联系人" ? 1 : 0, obj);
  188. break;
  189. }
  190. form[temporary.index] = temporary.item;
  191. wx.navigateBack()
  192. this.setData({
  193. form
  194. })
  195. },
  196. submit() {
  197. let content = {
  198. ...this.selectComponent("#Form").submit(),
  199. sa_quotedpriceid: 0
  200. };
  201. content.sys_enterpriseid = content.sys_enterpriseid[1] ? content.sys_enterpriseid[1][0] : 0;
  202. content.projectname = content.sa_projectid[0] || "";
  203. content.sa_projectid = content.sa_projectid[1] ? content.sa_projectid[1][0] : 0;
  204. content.contactsid = content.contactsid ? content.contactsid[1][0] : 0;
  205. content.begdate = content.invaliddate[0];
  206. content.enddate = content.invaliddate[1];
  207. delete(content.invaliddate)
  208. _Http.basic({
  209. "id": 20221020164803,
  210. "version": 1,
  211. content
  212. }).then(res => {
  213. console.log("添加项目报价单", res)
  214. wx.showToast({
  215. title: res.msg != '成功' ? res.msg : '保存成功',
  216. icon: "none"
  217. })
  218. if (res.msg != '成功') return;
  219. setTimeout(() => {
  220. let pages = getCurrentPages(),
  221. page = pages[pages.length - 2];
  222. if (page.__route__ == 'packageA/offers/index') {
  223. page.getList(true);
  224. } else if (page.__route__ == 'packageA/project/detail') {
  225. let model = page.selectComponent("#Offers");
  226. model.getList(model.data.sa_projectid, true);
  227. }
  228. wx.redirectTo({
  229. url: '/packageA/offers/detail?sa_quotedpriceid=' + res.data.sa_quotedpriceid
  230. })
  231. }, 300)
  232. })
  233. },
  234. // 是否显示全部
  235. onChange({
  236. detail
  237. }) {
  238. this.setData({
  239. showAll: detail
  240. })
  241. },
  242. /* 表单必填项是否完成 */
  243. onConfirm({
  244. detail
  245. }) {
  246. this.setData({
  247. disabled: detail
  248. })
  249. }
  250. })