AddManageMember.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <script>
  2. import { post, get } from '../../../../utils/request'
  3. export default {
  4. data() {
  5. return {
  6. active: 0,
  7. formData: {
  8. memberEmail: '',
  9. memberName: '',
  10. teamId: ''
  11. },
  12. teamList: {},
  13. file: {},
  14. click: true
  15. }
  16. },
  17. methods: {
  18. // 重置表单
  19. resetForm (formName) {
  20. this.$refs[formName].resetFields()
  21. this.$router.push("/manage-member")
  22. },
  23. //提交单个添加表单
  24. submitFormSingle(){
  25. if(this.click){
  26. this.click = false
  27. const regEmail = /^([A-Za-z0-9_\-.])+@([A-Za-z0-9_\-.])+\.([A-Za-z]{2,4})$/
  28. if (this.formData.memberEmail.trim() === '' || this.formData.teamId.trim() === '') {
  29. this.$message.error('Missing required information')
  30. //限制点击
  31. setTimeout(() => {
  32. this.click = true
  33. }, 3000)
  34. } else if(!regEmail.test(this.formData.memberEmail)){
  35. this.$message.error('Incorrect email format')
  36. //限制点击
  37. setTimeout(() => {
  38. this.click = true
  39. }, 3000)
  40. }
  41. else {
  42. post('/pdf-tech/vppTeam/addTeamMember',this.formData).then((res)=>{
  43. //限制点击
  44. setTimeout(() => {
  45. this.click = true
  46. }, 3000)
  47. if(res.data.code === 200){
  48. this.$message({
  49. message: 'Add Success!',
  50. type: "success",
  51. })
  52. } else if(res.data.msg === "Member has joined a non-default team"){
  53. this.$message({
  54. message: 'Member has joined a non-default team',
  55. type: "error",
  56. })
  57. }
  58. })
  59. }
  60. }
  61. },
  62. //提交批量添加表单
  63. submitFormVolume(){
  64. if(this.click){
  65. this.click = false
  66. this.$refs.upload.submit()
  67. const formData = new FormData()
  68. formData.append("file",this.file)
  69. post('/pdf-tech/vppTeam/addTeamMemberBatch', formData).then((res) => {
  70. //限制点击
  71. setTimeout(() => {
  72. this.click = true
  73. }, 1000)
  74. if(res.data.code === 200){
  75. this.$message({
  76. message: 'Add Success!',
  77. type: "success",
  78. })
  79. }
  80. })
  81. }
  82. },
  83. //批量上传文件
  84. upLoadChange(file){
  85. this.file = file
  86. return false
  87. }
  88. },
  89. mounted() {
  90. //获取团队列表
  91. get('/pdf-tech/vppTeam/listWithAdmin').then(
  92. (res) => {
  93. if(res.data.code === 200){
  94. this.teamList = res.data.result
  95. }
  96. }
  97. )
  98. }
  99. }
  100. </script>
  101. <template>
  102. <div>
  103. <h1 class="text-28px leading-40px mb-15px font-700">Add Member </h1>
  104. <div class="flex">
  105. <span
  106. class="
  107. flex
  108. justify-center
  109. bg-[#C6C9CC]
  110. rounded-t-8px
  111. items-center
  112. font-bold
  113. w-200px
  114. h-32px
  115. hand
  116. "
  117. @click="active = 0"
  118. :class="active === 0 ? 'active' : ''"
  119. >Single Add</span
  120. >
  121. <span
  122. class="
  123. flex
  124. justify-center
  125. bg-[#C6C9CC]
  126. rounded-t-8px
  127. items-center
  128. font-bold
  129. w-200px
  130. h-32px
  131. ml-8px
  132. hand
  133. "
  134. @click="active = 1"
  135. :class="active === 1 ? 'active' : ''"
  136. >Volume Add</span
  137. >
  138. </div>
  139. <div class="bg-[#fff] card">
  140. <!-- 单独加入 -->
  141. <el-form
  142. label-position="top"
  143. label-width="100px"
  144. class="p-40px"
  145. v-show="active === 0"
  146. :model="formData"
  147. ref="formData"
  148. >
  149. <el-form-item prop="memberEmail" class="required">
  150. <span slot="label" class="label">
  151. Member Email
  152. <span class="text-[#FF5054]">*</span>
  153. </span>
  154. <el-input v-model="formData.memberEmail" class="under-border" placeholder="Member Email"></el-input>
  155. </el-form-item>
  156. <el-form-item prop="memberName" class="under-border">
  157. <span slot="label" class="label">
  158. Member Name
  159. </span>
  160. <el-input v-model="formData.memberName" class="under-border" placeholder="Member Name"></el-input>
  161. </el-form-item>
  162. <el-form-item prop="team">
  163. <span slot="label" class="label">
  164. Team
  165. <span class="text-[#FF5054]">*</span>
  166. </span>
  167. <el-select
  168. v-model="formData.teamId"
  169. placeholder="Product Designer"
  170. class="w-[40%]"
  171. >
  172. <el-option
  173. v-for="item in teamList"
  174. :key="item.id"
  175. :label="item.name"
  176. :value="item.id"
  177. >
  178. </el-option>
  179. </el-select>
  180. </el-form-item>
  181. <el-form-item>
  182. <button
  183. type="button"
  184. @click="resetForm('formData')"
  185. class="
  186. w-168px
  187. h-48px
  188. border-1px border-[#1460F3]
  189. text-[#1460F3]
  190. rounded-8px
  191. font-bold
  192. mr-16px
  193. hover:opacity-80
  194. "
  195. >
  196. Cancel
  197. </button>
  198. <button
  199. type="button"
  200. @click="submitFormSingle()"
  201. class="
  202. w-168px
  203. h-48px
  204. bg-[#1460F3]
  205. text-[#fff]
  206. rounded-8px
  207. font-bold
  208. hover:opacity-80
  209. "
  210. >
  211. Add
  212. </button>
  213. </el-form-item>
  214. </el-form>
  215. <!-- 批量添加 -->
  216. <el-form
  217. label-position="top"
  218. label-width="100px"
  219. inline-message
  220. class="p-40px"
  221. v-show="active === 1"
  222. >
  223. <el-form-item>
  224. <span slot="label" class="label">
  225. XLSX with users
  226. <br>
  227. <span class="text-[14px] leading-20px text-[#808185]">
  228. Upload a XLSX file to add users.You can download the sample XLSX file for an example of the format.
  229. </span>
  230. </span>
  231. </el-form-item>
  232. <el-form-item>
  233. <el-upload
  234. class="upload-demo"
  235. drag
  236. action=""
  237. :before-upload="upLoadChange"
  238. :auto-upload="false"
  239. :limit="1"
  240. accept=".xlsx"
  241. ref="upload">
  242. <div class="el-upload__text">Drag or drop XLSX file here or <em>browse</em></div>
  243. </el-upload>
  244. </el-form-item>
  245. <el-form-item>
  246. <span slot="label" class="label leading-20px text-[#1460F3] hover:opacity-70 cursor-pointer">
  247. <a href="/public/download/团队成员导入模板.xlsx" download="团队成员导入模板.xlsx">
  248. Download sample XLSX <img src="@/assets/images/downLoadBlue.svg" class="inline-block ">
  249. </a>
  250. </span>
  251. </el-form-item>
  252. <el-form-item>
  253. <button
  254. type="button"
  255. @click="resetForm('formData')"
  256. class="
  257. w-168px
  258. h-48px
  259. border-1px border-[#1460F3]
  260. text-[#1460F3]
  261. rounded-8px
  262. mr-16px
  263. font-bold
  264. hover:opacity-80
  265. "
  266. >
  267. Cancel
  268. </button>
  269. <button
  270. type="button"
  271. @click="submitFormVolume()"
  272. class="
  273. w-168px
  274. h-48px
  275. bg-[#1460F3]
  276. text-[#fff]
  277. rounded-8px
  278. font-bold
  279. hover:opacity-80
  280. "
  281. >
  282. Add
  283. </button>
  284. </el-form-item>
  285. </el-form>
  286. </div>
  287. </div>
  288. </template>
  289. <style lang="scss" scoped>
  290. .hand {
  291. cursor: pointer;
  292. }
  293. .el-form-item::v-deep label {
  294. color: #232a40 !important;
  295. }
  296. .active {
  297. color: #1460f3;
  298. background-color: #fff;
  299. }
  300. .card {
  301. border-radius: 8px;
  302. border-top-left-radius: 0px;
  303. }
  304. .el-input::v-deep input {
  305. border: 0px !important;
  306. border-bottom: 1px solid #d9d9d9 !important;
  307. // border-radius: 6px !important;
  308. }
  309. .username::v-deep input {
  310. border-radius: 0px !important;
  311. }
  312. .email::v-deep input {
  313. border: 0px !important;
  314. }
  315. .required::v-deep label::before {
  316. display: none;
  317. }
  318. .el-form-item::v-deep label {
  319. font-weight: 700;
  320. padding: 0;
  321. margin-left: 8px;
  322. }
  323. .el-select-dropdown::v-deep .popper__arrow {
  324. display: none;
  325. }
  326. ::v-deep .el-upload__text{
  327. margin: 70px 0;
  328. color: #808185;
  329. }
  330. ::v-deep .el-upload-dragger{
  331. border: 1px solid #d9d9d9;
  332. width: 100%;
  333. }
  334. ::v-deep .el-upload{
  335. width: 50%;
  336. }
  337. ::v-deep .el-upload-list__item{
  338. width: 50%;
  339. }
  340. </style>
  341. <style lang="scss">
  342. .popper__arrow {
  343. display: none !important;
  344. }
  345. .el-select-dropdown {
  346. margin-top: 0 !important;
  347. }
  348. .el-message--success {
  349. margin-top: 90px !important;
  350. background-color: #373A47 !important;
  351. height: 36px;
  352. min-width: auto !important;
  353. padding: 12px !important;
  354. p{
  355. color: #fff !important;
  356. }
  357. }
  358. .el-message--error {
  359. border-color: #ff5054 !important;
  360. height: 36px;
  361. min-width: auto !important;
  362. padding: 12px !important;
  363. }
  364. </style>