addAndEditor.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. showAll: false,
  5. form: [{
  6. label: "企业名称",
  7. error: false,
  8. errMsg: "",
  9. type: "textarea",
  10. value: "",
  11. placeholder: "企业全称",
  12. valueName: "enterprisename",
  13. checking: "base",
  14. required: true
  15. }, {
  16. label: "选择公海池",
  17. error: false,
  18. errMsg: "",
  19. type: "route",
  20. url: "/packageA/publicCustomer/pond/index",
  21. radio: true,
  22. value: "",
  23. params: {
  24. "id": 20221206195102,
  25. "content": {
  26. "pageNumber": 1,
  27. "pageSize": 20,
  28. "where": {
  29. "condition": ""
  30. }
  31. }
  32. },
  33. placeholder: "选择所属公海池",
  34. valueName: "sa_customerpoolid",
  35. checking: "base",
  36. required: true
  37. }, {
  38. label: "企业简称",
  39. error: false,
  40. errMsg: "",
  41. type: "textarea",
  42. value: "",
  43. placeholder: "企业简称",
  44. valueName: "abbreviation",
  45. checking: "base",
  46. required: false
  47. }, {
  48. label: "统一社会信用代码",
  49. error: false,
  50. errMsg: "",
  51. type: "textarea",
  52. value: "",
  53. placeholder: "企业税号/注册号/营业执照号码",
  54. valueName: "taxno",
  55. checking: "base",
  56. required: false
  57. }, {
  58. label: "法定代表人",
  59. error: false,
  60. errMsg: "",
  61. type: "text",
  62. value: "",
  63. placeholder: "企业法人",
  64. valueName: "contact",
  65. checking: "base",
  66. required: false
  67. }, {
  68. label: "法人电话号码",
  69. error: false,
  70. errMsg: "",
  71. type: "number",
  72. value: "",
  73. placeholder: "法人联系手机号",
  74. valueName: "phonenumber",
  75. checking: "phone",
  76. required: false
  77. }, {
  78. label: "所属行业",
  79. error: false,
  80. errMsg: "",
  81. type: "option", //自定义选择 配合预定接口
  82. optionNmae: "industry", //选择类型
  83. optionType: "radio", //复选 radio 单选
  84. value: "",
  85. placeholder: "企业所属行业",
  86. valueName: "industry",
  87. checking: "base",
  88. required: false
  89. }, {
  90. label: "地区",
  91. error: false,
  92. errMsg: "",
  93. type: "region",
  94. value: [],
  95. placeholder: "所属地区 省/市/区",
  96. valueName: "region",
  97. required: false
  98. }, {
  99. label: "注册地址",
  100. error: false,
  101. errMsg: "",
  102. type: "textarea",
  103. value: "",
  104. placeholder: "企业注册地址",
  105. valueName: "address",
  106. checking: "base",
  107. required: false
  108. }, {
  109. label: "客户类型",
  110. error: false,
  111. errMsg: "",
  112. type: "option",
  113. optionNmae: "customertypemx",
  114. optionType: "radio", //复选 radio 单选
  115. value: "",
  116. placeholder: "客户类型",
  117. valueName: "type",
  118. checking: "base",
  119. required: true
  120. }, {
  121. label: "客户级别",
  122. error: false,
  123. errMsg: "",
  124. type: "option",
  125. optionNmae: "agentgrade",
  126. optionType: "radio", //复选 radio 单选
  127. value: "",
  128. placeholder: "客户数字级别",
  129. valueName: "grade",
  130. checking: "base",
  131. required: false
  132. }],
  133. content: {
  134. "sa_customersid": 0, //新增是传0
  135. "parentid": 0, //上级客户ID,默认或没有上级的时候传0
  136. "sys_enterpriseid": 0, //合作企业档案ID,新增是传0,更新
  137. "source": "", //客户来源
  138. },
  139. disabled: true
  140. },
  141. setOption(item) {
  142. let i = this.data.form.findIndex(v => v.valueName == item.valueName);
  143. this.setData({
  144. [`form[${i}]`]: item
  145. })
  146. },
  147. onLoad(options) {
  148. if (options.data) {
  149. let data = JSON.parse(options.data);
  150. this.setData({
  151. disabled: false,
  152. content: {
  153. sa_customersid: data.sa_customersid,
  154. parentid: data.parentid,
  155. sys_enterpriseid: data.sys_enterpriseid,
  156. sa_customerpoolid: data.sa_customerpoolid,
  157. source: data.source,
  158. },
  159. form: this.data.form.map(v => {
  160. if (v.valueName != 'region') {
  161. v.value = data[v.valueName];
  162. } else {
  163. v.value = data.province ? [data.province, data.city, data.county] : []
  164. }
  165. return v
  166. })
  167. })
  168. }
  169. },
  170. /* 表单必填项是否完成 */
  171. onConfirm({
  172. detail
  173. }) {
  174. this.setData({
  175. disabled: detail
  176. })
  177. },
  178. // 是否显示全部
  179. onChange({
  180. detail
  181. }) {
  182. this.setData({
  183. showAll: detail
  184. })
  185. },
  186. submit() {
  187. let data = this.selectComponent("#Form").submit();
  188. if (data.region.length != 0) {
  189. data.province = data.region[0]
  190. data.city = data.region[1]
  191. data.county = data.region[2]
  192. };
  193. data.sa_customerpoolid = data.sa_customerpoolid[1][0]
  194. delete(data.region);
  195. _Http.basic({
  196. "id": 20221010164302,
  197. "content": {
  198. ...this.data.content,
  199. ...data,
  200. }
  201. }).then(res => {
  202. console.log("新建客户", res)
  203. if (res.msg != '成功') return wx.showToast({
  204. title: res.data,
  205. icon: "none"
  206. })
  207. wx.showToast({
  208. title: '保存成功',
  209. icon: "none"
  210. })
  211. setTimeout(() => {
  212. getCurrentPages().forEach(v => {
  213. switch (v.__route__) {
  214. case 'packageA/publicCustomer/index':
  215. v.getList(true);
  216. break;
  217. case 'packageA/publicCustomer/detail':
  218. wx.navigateBack()
  219. v.getDetail();
  220. break;
  221. }
  222. })
  223. let pages = getCurrentPages();
  224. if (pages[pages.length - 2].__route__ == 'packageA/publicCustomer/index') wx.redirectTo({
  225. url: '/packageA/publicCustomer/detail?id=' + res.data.sa_customersid,
  226. })
  227. }, 300)
  228. })
  229. },
  230. })