createDialog.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <div class="dialog-main">
  3. <el-dialog
  4. :title="title"
  5. :visible.sync="show"
  6. width="262px"
  7. :modal-append-to-body="false"
  8. :close-on-click-modal="true"
  9. :class="{'bizId-dialog':bizSelect}"
  10. top="15vh"
  11. @close="cancel()"
  12. >
  13. <article>
  14. <div v-show="!bizSelect" class="select-section">
  15. <div class="select-schedule" @click="create('schedule')">
  16. <span class="select-icon">
  17. <i class="el-icon-document" />
  18. </span>
  19. 新建排期
  20. </div>
  21. <div class="select-calendar" @click="create('calendar')">
  22. <span class="select-icon">
  23. <i class="el-icon-date" />
  24. </span>
  25. 新建日程
  26. </div>
  27. </div>
  28. <div v-show="bizSelect" class="select-bizId">
  29. <i class="el-icon-arrow-left" @click="bizSelect = false;title = '请选择'" />
  30. <el-select v-model="bizId" size="medium" placeholder="业务线(必选)" style="width:100%" filterable>
  31. <el-option-group v-for="group in bizList" :key="group.code" :label="group.name">
  32. <el-option v-for="item in group.options" :key="item.code" :label="item.name" :value="item.code" />
  33. </el-option-group>
  34. </el-select>
  35. </div>
  36. </article>
  37. <span v-show="bizSelect" slot="footer" class="dialog-footer">
  38. <el-button size="small" @click="cancel()">取 消</el-button>
  39. <el-button type="primary" size="small" @click="confirm()">确定</el-button>
  40. </span>
  41. </el-dialog>
  42. </div>
  43. </template>
  44. <script>
  45. import { settingGetMyAndOtherBizList } from '@/api/projectIndex'
  46. export default {
  47. props: {
  48. visible: {
  49. type: Boolean,
  50. default: false,
  51. required: true
  52. }
  53. },
  54. data() {
  55. return {
  56. show: this.visible,
  57. title: '请选择',
  58. bizSelect: false,
  59. bizList: [],
  60. bizId: null
  61. }
  62. },
  63. watch: {
  64. visible: {
  65. handler(newV, old) {
  66. this.show = newV
  67. },
  68. immediate: true
  69. },
  70. bizSelect: {
  71. handler(newV) {
  72. this.title = newV ? '新建排期' : '请选择'
  73. },
  74. immediate: true
  75. }
  76. },
  77. created() {
  78. this.settingGetBizList()
  79. },
  80. methods: {
  81. async settingGetBizList() { // 获取业务线列表
  82. const res = await settingGetMyAndOtherBizList()
  83. if (res.code === 200) {
  84. this.$nextTick(() => {
  85. const biz = res.data.filter(item => item.length > 0)
  86. this.bizId = biz[0].code
  87. })
  88. this.bizList = [{
  89. name: '我的业务线',
  90. options: res.data[0] || []
  91. }, {
  92. name: '其他业务线',
  93. options: res.data[1] ? res.data[1].filter(item => item.isSecret !== 1) : []
  94. }]
  95. }
  96. },
  97. create(type) {
  98. if (type === 'calendar') {
  99. this.$emit('change')
  100. } else if (type === 'schedule') {
  101. this.bizSelect = true
  102. }
  103. },
  104. confirm() {
  105. if (!this.bizId) {
  106. this.$message({ type: 'warning', message: '请选择业务线!' })
  107. return false
  108. }
  109. const list = this.bizList.reduce((pre, cur) => {
  110. return [...pre.options, ...cur.options]
  111. })
  112. this.$emit('change', list.find(item => item.code === this.bizId))
  113. },
  114. cancel() { // 关闭弹框
  115. this.show = false
  116. this.bizSelect = false
  117. this.bizId = null
  118. this.$emit('update:visible', this.show)
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. >>>.el-dialog__header {
  125. padding: 20px !important;
  126. }
  127. >>>.el-dialog__body {
  128. padding: 0;
  129. }
  130. >>>.el-dialog__title{
  131. padding-left: 10px;
  132. position: relative;
  133. }
  134. >>>.el-dialog__title::before {
  135. content:" ";
  136. display: inline-block;
  137. position: absolute;
  138. top: 2px;
  139. left: 0;
  140. width: 5px;
  141. height: 20px;
  142. background-color: rgb(64, 158, 255);
  143. }
  144. .bizId-dialog {
  145. >>>.el-dialog__title::before {
  146. content:"";
  147. background-color: #FFFFFF;
  148. }
  149. }
  150. .el-icon-arrow-left {
  151. position: absolute;
  152. top: 24px;
  153. left: 10px;
  154. font-size: 18px;
  155. }
  156. .select-bizId {
  157. margin-bottom: 25px;
  158. padding: 0 20px;
  159. }
  160. .select-section {
  161. width: 100%;
  162. height: 100px;
  163. display: flex;
  164. flex-direction: column;
  165. justify-content: center;
  166. color: #333B4A;
  167. .select-icon {
  168. height: 30px;
  169. width: 30px;
  170. margin-right: 10px;
  171. display: flex;
  172. justify-content: center;
  173. align-items: center;
  174. border-radius: 50%;
  175. background-color: rgba(64, 158, 255,1);
  176. color: #FFFFFF;
  177. }
  178. .select-schedule,.select-calendar {
  179. cursor: pointer;
  180. border-radius: 4px;
  181. font-size: 18px;
  182. height: 50%;
  183. width: 100%;
  184. display: flex;
  185. padding-left: 32px;
  186. align-items: center;
  187. }
  188. .select-calendar {
  189. .select-icon {
  190. background-color: #61D3B8;
  191. }
  192. }
  193. .select-schedule:hover{
  194. color:rgb(64, 158, 255);
  195. background-color: #EDEDED;
  196. }
  197. .select-calendar:hover{
  198. color:rgb(64, 158, 255);
  199. background-color: #EDEDED;
  200. }
  201. }
  202. </style>