insert.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view>
  3. <my_form
  4. ref="form"
  5. :form="form"
  6. @isUncomplete="isUncomplete"
  7. @interrupt="interrupt"
  8. requiredFieldOnly
  9. />
  10. <view style="height: 70px" />
  11. <view class="footer">
  12. <view
  13. class="add"
  14. @click="uncomplete || loading ? '' : submit()"
  15. :class="uncomplete ? 'forbidden' : ''"
  16. hover-class=" navigator-hover"
  17. >
  18. <u-loading-icon v-if="loading" />
  19. <block v-else> 提交 </block>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. sys_enterprise_hrid: 0,
  29. form: [],
  30. uncomplete: true,
  31. loading: false,
  32. };
  33. },
  34. async onLoad(options) {
  35. uni.setNavigationBarTitle({
  36. title: options.title || "新增人员",
  37. });
  38. let form = [
  39. {
  40. key: "name",
  41. type: "text",
  42. label: "姓名",
  43. isMust: true, //是否必填
  44. value: "",
  45. },
  46. {
  47. key: "phonenumber",
  48. type: "text",
  49. label: "手机号",
  50. isMust: true, //是否必填
  51. value: "",
  52. placeholder: "请输入收货人手机号",
  53. inputmode: "number",
  54. verify: [this.getReg("phonenumber")],
  55. },
  56. {
  57. key: "sex",
  58. type: "sex",
  59. label: "性别",
  60. value: "男",
  61. },
  62. {
  63. key: "birthday",
  64. type: "date",
  65. label: "生日",
  66. value: "",
  67. placeholder: "请选择出生日期",
  68. },
  69. {
  70. key: "email",
  71. type: "text",
  72. label: "邮箱",
  73. isMust: false, //是否必填
  74. value: "",
  75. verify: [this.getReg("email")],
  76. },
  77. {
  78. key: "position",
  79. type: "text",
  80. label: "店内职位",
  81. isMust: false, //是否必填
  82. value: "",
  83. },
  84. {
  85. key: "sa_storeids",
  86. type: "route",
  87. path: "/select/store/store",
  88. isRadio: false,
  89. label: "所属门店",
  90. isMust: false, //是否必填
  91. value: [],
  92. showValue: [],
  93. },
  94. ];
  95. if (options.data) {
  96. let data = JSON.parse(options.data);
  97. this.sys_enterprise_hrid = data.sys_enterprise_hrid;
  98. form = form.map((v) => {
  99. switch (v.key) {
  100. case "sa_storeids":
  101. v.showValue = data.storenames ? data.storenames.split(",") : [];
  102. v.value = data.sa_storeids || [];
  103. break;
  104. default:
  105. v.value = data[v.key] || "";
  106. break;
  107. }
  108. if (data.status == "启用" && v.isMust) v.disabled = true;
  109. return v;
  110. });
  111. /* if (data.iswechatbind) form.splice(6, 0, {
  112. key: "roleids",
  113. type: "route",
  114. path: "/select/roleid/roleid?sys_enterprise_hrid=" + data.sys_enterprise_hrid,
  115. isRadio: false,
  116. label: "角色",
  117. isMust: true,//是否必填
  118. value: data.roleids || [],
  119. showValue: data.rolenames ? data.rolenames.split(",") : [],
  120. }) */
  121. }
  122. this.form = form;
  123. },
  124. methods: {
  125. isUncomplete(uncomplete) {
  126. this.uncomplete = uncomplete;
  127. },
  128. interrupt(item, selected, index) {
  129. switch (item.key) {
  130. default:
  131. item.showValue = selected.showValue || [];
  132. item.value = selected.value || [];
  133. this.$refs.form.setItem(index, item, true);
  134. break;
  135. }
  136. },
  137. submit() {
  138. this.loading = true;
  139. let that = this;
  140. this.$refs.form.submit().then((data) => {
  141. data.sa_storeids = data.sa_storeids.value;
  142. if (data.roleids) data.roleids = data.roleids.value;
  143. this.$Http
  144. .basic({
  145. id: 20240410164102,
  146. content: {
  147. sys_enterprise_hrid: this.sys_enterprise_hrid,
  148. ...data,
  149. },
  150. })
  151. .then((res) => {
  152. this.loading = false;
  153. console.log("加入团队", res);
  154. if (this.cutoff(res.msg)) return;
  155. this.loading = true;
  156. this.$Http.uploadUserList && this.$Http.uploadUserList();
  157. if (this.sys_enterprise_hrid == 0) {
  158. uni.showModal({
  159. title: "新增成功",
  160. content: "人员新增成功!是否立即查看",
  161. cancelText: "返回",
  162. confirmText: "查看",
  163. success: ({ confirm }) => {
  164. if (confirm) {
  165. uni.redirectTo({
  166. url:
  167. "/team/userCenter/personal?id=" +
  168. res.data.sys_enterprise_hrid,
  169. });
  170. } else {
  171. uni.navigateBack();
  172. }
  173. },
  174. });
  175. } else {
  176. this.$Http.uploadUserDetail && this.$Http.uploadUserDetail();
  177. uni.showToast({
  178. title: "编辑成功",
  179. icon: "none",
  180. duration: 1500,
  181. mask: true,
  182. });
  183. setTimeout(() => {
  184. uni.navigateBack();
  185. }, 800);
  186. }
  187. });
  188. });
  189. },
  190. },
  191. };
  192. </script>
  193. <style lang="scss" scoped>
  194. .footer {
  195. position: fixed;
  196. bottom: 0;
  197. width: 100vw;
  198. height: 65px;
  199. background: #ffffff;
  200. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  201. box-sizing: border-box;
  202. padding: 5px 10px;
  203. z-index: 999;
  204. .add {
  205. display: flex;
  206. align-items: center;
  207. justify-content: center;
  208. width: 100%;
  209. height: 45px;
  210. background: #c30d23;
  211. border-radius: 5px;
  212. font-family: PingFang SC, PingFang SC;
  213. font-size: 14px;
  214. color: #ffffff;
  215. }
  216. .forbidden {
  217. opacity: 0.6;
  218. }
  219. }
  220. </style>