insert.vue 6.0 KB

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