add.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="task-input-box">
  3. <div v-if="!addText" class="input-placeholder">
  4. <Icon type="md-create" size="18"/>&nbsp;{{addFocus?`${$L('输入任务,回车即可保存')}`:placeholder}}
  5. </div>
  6. <div class="input-enter">
  7. <Input
  8. v-model="addText"
  9. type="textarea"
  10. class="input-enter-textarea"
  11. :class="{bright:addFocus===true,highlight:!!addText}"
  12. element-id="project-panel-enter-textarea"
  13. @on-focus="addFocus=true"
  14. @on-blur="addFocus=false"
  15. :autosize="{ minRows: 1, maxRows: 6 }"
  16. :maxlength="255"
  17. @on-keydown="addKeydown"/>
  18. <div v-if="!!addText" class="input-enter-module">
  19. <Tooltip :content="$L('重要且紧急')" placement="bottom" transfer><div @click="addLevel=1" class="enter-module-icon p1"><Icon v-if="addLevel=='1'" type="md-checkmark" /></div></Tooltip>
  20. <Tooltip :content="$L('重要不紧急')" placement="bottom" transfer><div @click="addLevel=2" class="enter-module-icon p2"><Icon v-if="addLevel=='2'" type="md-checkmark" /></div></Tooltip>
  21. <Tooltip :content="$L('紧急不重要')" placement="bottom" transfer><div @click="addLevel=3" class="enter-module-icon p3"><Icon v-if="addLevel=='3'" type="md-checkmark" /></div></Tooltip>
  22. <Tooltip :content="$L('不重要不紧急')" placement="bottom" transfer><div @click="addLevel=4" class="enter-module-icon p4"><Icon v-if="addLevel=='4'" type="md-checkmark" /></div></Tooltip>
  23. <div class="enter-module-flex"></div>
  24. <Poptip placement="bottom" @on-popper-show="nameTipDisabled=true" @on-popper-hide="nameTipDisabled=false" transfer>
  25. <Tooltip :content="`${$L('负责人')}: ${addUsername||$L('自己')}`" placement="bottom" :disabled="nameTipDisabled">
  26. <div class="enter-module-icon user">
  27. <img v-if="addUserimg" @error="addUserimg=''" :src="addUserimg"/>
  28. <Icon v-else type="md-person" />
  29. </div>
  30. </Tooltip>
  31. <div slot="content">
  32. <div style="width:240px">
  33. {{$L('选择负责人')}}
  34. <UserInput v-model="addUsername" :projectid="projectid" @change="changeUser" :placeholder="$L('留空默认: 自己')" style="margin:5px 0 3px"></UserInput>
  35. </div>
  36. </div>
  37. </Poptip>
  38. <Button class="enter-module-btn" type="info" size="small" @click="clickAdd">{{$L('添加任务')}}</Button>
  39. </div>
  40. </div>
  41. <div v-if="loadIng > 0" class="load-box" @click.stop="">
  42. <div class="load-box-main"><w-loading></w-loading></div>
  43. </div>
  44. </div>
  45. </template>
  46. <style lang="scss" scoped>
  47. .task-input-box {
  48. position: relative;
  49. margin-top: 5px;
  50. margin-bottom: 20px;
  51. min-height: 70px;
  52. .input-placeholder,
  53. .input-enter {
  54. position: absolute;
  55. top: 0;
  56. left: 0;
  57. right: 0;
  58. width: 100%;
  59. }
  60. .input-placeholder {
  61. z-index: 1;
  62. height: 40px;
  63. line-height: 40px;
  64. color: rgba(0, 0, 0, .36);
  65. padding-left: 12px;
  66. padding-right: 12px;
  67. }
  68. .input-enter {
  69. z-index: 2;
  70. position: relative;
  71. background-color: transparent;
  72. .input-enter-textarea {
  73. border-radius: 4px;
  74. padding-left: 12px;
  75. padding-right: 12px;
  76. color: rgba(0, 0, 0, 0.85);
  77. &.bright {
  78. background-color: rgba(46, 73, 136, .08);
  79. }
  80. &.highlight {
  81. background-color: #ffffff;
  82. }
  83. }
  84. .input-enter-module {
  85. display: flex;
  86. width: 100%;
  87. margin-top: 8px;
  88. .enter-module-icon {
  89. display: inline-block;
  90. width: 16px;
  91. height: 16px;
  92. margin-right: 5px;
  93. border-radius: 4px;
  94. vertical-align: middle;
  95. cursor: pointer;
  96. &.p1 {
  97. background-color: #ff0000;
  98. }
  99. &.p2 {
  100. background-color: #BB9F35;
  101. }
  102. &.p3 {
  103. background-color: #449EDD;
  104. }
  105. &.p4 {
  106. background-color: #84A83B;
  107. }
  108. &.user {
  109. background-color: #98CD75;
  110. border-radius: 50%;
  111. width: 24px;
  112. height: 24px;
  113. margin-left: 10px;
  114. margin-right: 10px;
  115. img {
  116. width: 100%;
  117. height: 100%;
  118. border-radius: 50%;
  119. }
  120. i {
  121. line-height: 24px;
  122. font-size: 16px;
  123. }
  124. }
  125. i {
  126. width: 100%;
  127. height: 100%;
  128. color: #ffffff;
  129. line-height: 16px;
  130. font-size: 14px;
  131. transform: scale(0.85);
  132. vertical-align: 0;
  133. }
  134. }
  135. .enter-module-flex {
  136. flex: 1;
  137. }
  138. .enter-module-btn {
  139. font-size: 12px;
  140. }
  141. }
  142. }
  143. .load-box {
  144. position: absolute;
  145. top: 0;
  146. left: 0;
  147. right: 0;
  148. bottom: 0;
  149. display: flex;
  150. align-items: center;
  151. justify-content: center;
  152. z-index: 9;
  153. .load-box-main {
  154. width: 24px;
  155. height: 24px;
  156. }
  157. }
  158. }
  159. </style>
  160. <script>
  161. export default {
  162. name: 'ProjectAddTask',
  163. props: {
  164. placeholder: {
  165. type: String,
  166. default: ''
  167. },
  168. projectid: {
  169. type: Number,
  170. default: 0
  171. },
  172. labelid: {
  173. type: Number,
  174. default: 0
  175. },
  176. },
  177. data() {
  178. return {
  179. loadIng: 0,
  180. addText: '',
  181. addLevel: 2,
  182. addUsername: '',
  183. addUserimg: '',
  184. addFocus: false,
  185. nameTipDisabled: false,
  186. }
  187. },
  188. methods: {
  189. changeUser(user) {
  190. this.addUserimg = user.userimg;
  191. },
  192. clickAdd() {
  193. let addText = this.addText.trim();
  194. if ($A.count(addText) == 0 || this.loadIng > 0) {
  195. return;
  196. }
  197. this.loadIng++;
  198. $A.aAjax({
  199. url: 'project/task/add',
  200. data: {
  201. projectid: this.projectid,
  202. labelid: this.labelid,
  203. title: addText,
  204. level: this.addLevel,
  205. username: this.addUsername,
  206. },
  207. complete: () => {
  208. this.loadIng--;
  209. },
  210. error: () => {
  211. alert(this.$L('网络繁忙,请稍后再试!'));
  212. },
  213. success: (res) => {
  214. if (res.ret === 1) {
  215. this.addText = '';
  216. this.addFocus = false;
  217. this.$Message.success(res.msg);
  218. this.$emit('on-add-success', res.data);
  219. $A.triggerTaskInfoListener('create', res.data);
  220. $A.triggerTaskInfoChange(res.data.id);
  221. } else {
  222. this.$Modal.error({title: this.$L('温馨提示'), content: res.msg});
  223. }
  224. }
  225. });
  226. },
  227. addKeydown(e) {
  228. e = e || event;
  229. if (e.keyCode == 13) {
  230. if (e.shiftKey) {
  231. return;
  232. }
  233. this.clickAdd();
  234. e.preventDefault();
  235. }
  236. }
  237. }
  238. }
  239. </script>