leader-mailbox.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div id="app">
  3. <div v-show="show">
  4. <van-nav-bar title="领导信箱" left-arrow @click-left="onClickLeft" />
  5. </div>
  6. <!-- 输入姓名,留言点击上传数据库 -->
  7. <div class="inputAll">
  8. <!-- 提交form表单 -->
  9. <form @submit.prevent="submit(staff_num)">
  10. <div class="input-name">
  11. <span class="span-name">姓名:</span>
  12. <!-- input事件用来点击复选框时显示原本姓名还是匿名 -->
  13. <input
  14. type="text"
  15. name="姓名"
  16. placeholder="请输入姓名"
  17. class="input-border"
  18. v-model="username"
  19. readonly
  20. />
  21. <!-- 这里的v-model用来控制是匿名还是非匿名 -->
  22. <div>
  23. <van-checkbox
  24. v-model="checked"
  25. shape="square"
  26. @click="userNameChange"
  27. >匿名</van-checkbox
  28. >
  29. </div>
  30. </div>
  31. <div class="input-message">
  32. <van-field
  33. v-model="content"
  34. rows="5"
  35. colon="true"
  36. name="留言"
  37. label="留言"
  38. type="textarea"
  39. placeholder="请输入留言"
  40. />
  41. </div>
  42. <div class="input-button">
  43. <input type="submit" value="提交" />
  44. </div>
  45. </form>
  46. </div>
  47. </div>
  48. </template>
  49. <script>
  50. import { getAllUrlParams } from "../plugins/admin/url-encapsulation.js";
  51. export default {
  52. data() {
  53. return {
  54. checked: 0, //当前复选框不为选中状态
  55. content: "", //留言内容
  56. username: "", //员工姓名
  57. staff_num: "", //员工编号
  58. token: sessionStorage.getItem("mytoken")
  59. ? sessionStorage.getItem("mytoken")
  60. : "", //token值保存在本地,有的话取值,没有为空
  61. show: false, //tabber是否显示
  62. myshow:false,
  63. gettoken: "", //从url获取到token值
  64. name: "", //员工姓名赋值
  65. leader: true, //是否为领导
  66. };
  67. },
  68. methods: {
  69. //点击事件提交到领导信箱的数据库
  70. submit(num) {
  71. if (this.username == "" || this.content == "") {
  72. this.$toast("请填写留言内容");
  73. } else {
  74. this.$http
  75. .post("/api/workbench/leader_mailbox/add", {
  76. staff_num: num,
  77. status: this.checked,
  78. content: this.content,
  79. name: this.username,
  80. })
  81. .then((res) => {});
  82. //获得提示表明已提交意见
  83. this.$router.push(`/xixuanzhongxin/leader-mailbox/leader-success`);
  84. }
  85. },
  86. //获取checked的属性值
  87. userNameChange() {
  88. //当checked等于true的时候表单内容被*号覆盖
  89. if (this.checked == true) {
  90. let inputUserName = this.username;
  91. inputUserName = inputUserName.replace(/./g, "*");
  92. this.username = inputUserName;
  93. } else {
  94. this.username = this.name;
  95. }
  96. },
  97. //返回上一页面
  98. onClickLeft() {
  99. window.history.back();
  100. },
  101. //获取个人信息
  102. getxinxi() {
  103. this.$http
  104. .post("http://xixuan.nxjiewei.com:8011/api/user/info")
  105. .then((res) => {
  106. this.staff_num = res.data.data.staff_num;
  107. this.username = res.data.data.name;
  108. this.name = res.data.data.name;
  109. if (this.checked == true) {
  110. let inputUserName = this.username;
  111. inputUserName = inputUserName.replace(/./g, "*");
  112. this.username = inputUserName;
  113. if (this.checked == false) {
  114. this.username = this.name;
  115. }
  116. }
  117. })
  118. .catch((err) => {
  119. console.log(err);
  120. });
  121. },
  122. //页面进入是判断是否为领导,是领导跳转至领导信箱列表页
  123. Jumpleader() {
  124. this.$http
  125. .post(
  126. "http://xixuan.nxjiewei.com:8011/api/workbench/leader_mailbox/check"
  127. )
  128. .then((res) => {
  129. //获取是否为领导
  130. this.leader = res.data.data;
  131. if (this.leader == true) {
  132. this.$router.push(`/xixuanzhongxin/leader-mailbox/leader-mailbox-list2?token=${this.token}`)
  133. }
  134. });
  135. },
  136. },
  137. //这里挂载的是获取token
  138. mounted() {
  139. document.body.style.backgroundColor = "#3399ff";
  140. this.token=this.$route.query.token;
  141. this.show=this.myshow
  142. // this.gettoken =getAllUrlParams(window.location.href).token;
  143. // this.token = `Bearer ${this.gettoken}`;
  144. // sessionStorage.setItem("mytoken", this.token);
  145. // this.show = Boolean(getAllUrlParams(window.location.href).tabber);
  146. this.getxinxi();
  147. },
  148. created() {
  149. // this.Jumpleader();
  150. this.myshow =Boolean(getAllUrlParams(window.location.href).tabber);
  151. },
  152. };
  153. </script>
  154. <style scoped>
  155. .h1 {
  156. text-align: center;
  157. color: #fff;
  158. font-weight: 500;
  159. font-size: 20px;
  160. }
  161. >>> .van-cell {
  162. margin-bottom: 3%;
  163. border-radius: 10px;
  164. }
  165. >>> .van-button--info {
  166. color: #39f;
  167. background-color: #fff;
  168. }
  169. .input-name {
  170. display: flex;
  171. justify-content: space-around;
  172. margin: 0 auto;
  173. width: 90%;
  174. height: 50px;
  175. line-height: 50px;
  176. margin-bottom: 3%;
  177. background: #fff;
  178. border-radius: 10px;
  179. margin-top: 3%;
  180. }
  181. .span-name {
  182. font-size: 14px;
  183. color: #97a3b4;
  184. margin-left: 10px;
  185. }
  186. .input-border {
  187. border: none;
  188. }
  189. .input-border::-webkit-input-placeholder {
  190. color: #cccdcf;
  191. font-size: 14px;
  192. }
  193. .input-button {
  194. width: 85%;
  195. background: #fff;
  196. height: 40px;
  197. text-align: center;
  198. margin: auto;
  199. line-height: 40px;
  200. border-radius: 10px;
  201. margin-top: 5%;
  202. }
  203. .input-button > input {
  204. background: #fff;
  205. border: none;
  206. color: #39f;
  207. }
  208. .input-checkbox {
  209. line-height: 40px;
  210. }
  211. .input-message {
  212. width: 90%;
  213. margin: 0 auto;
  214. }
  215. >>> .van-checkbox {
  216. margin-top: 10px;
  217. }
  218. >>> .van-checkbox__icon .van-icon {
  219. width: 20px;
  220. height: 20px;
  221. }
  222. >>> .van-checkbox__label {
  223. margin-left: 3px;
  224. margin-top: 10%;
  225. color: #97a3b4;
  226. line-height: 10px;
  227. font-size: 16px;
  228. }
  229. >>> .van-checkbox__icon {
  230. margin-top: 5px;
  231. }
  232. >>> .input-message span {
  233. color: #97a3b4;
  234. }
  235. .leader-h1 {
  236. position: relative;
  237. }
  238. .leader-h1-img {
  239. position: absolute;
  240. left: 9%;
  241. top: 25%;
  242. }
  243. .leader-h1-img > img {
  244. width: 15px;
  245. height: 18px;
  246. }
  247. >>> .van-nav-bar {
  248. background: #39f;
  249. }
  250. >>> .van-field__label {
  251. margin-right: 5px;
  252. }
  253. >>> .van-nav-bar__title,
  254. .van-nav-bar .van-icon,
  255. .van-nav-bar__text {
  256. color: #fff;
  257. }
  258. >>> [class*="van-hairline"]:after {
  259. border: none;
  260. }
  261. >>> .van-field__label {
  262. width: 3.2em;
  263. }
  264. </style>