processSet.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div :class="'process-set '+type" v-loading="loading">
  3. <process-set-item :list="list" :type="operationType"></process-set-item>
  4. <el-dialog :close-on-click-modal="false" :title="isUpdate?'编辑':'新增'" :visible.sync="visible" width="900px"
  5. :append-to-body="true">
  6. <process-form v-if="visible" @callback="callback" :isUpdate="isUpdate" :itemId="itemId" :type="type"
  7. :partId="part.id">
  8. </process-form>
  9. </el-dialog>
  10. </div>
  11. </template>
  12. <script>
  13. const processSetItem = () => import('./processSetItem.vue');
  14. const processForm = () => import('./processForm');
  15. import {
  16. getProcessSetData,
  17. deleteProcessSetData,
  18. getProcessData,
  19. deleteProcessData,
  20. } from '@/api/system'
  21. import {
  22. mapGetters
  23. } from 'vuex';
  24. export default {
  25. props: ['part', 'type', 'operationType'],
  26. data() {
  27. return {
  28. list: [],
  29. loading: false,
  30. itemId: '',
  31. visible: false,
  32. isUpdate: false
  33. }
  34. },
  35. mounted() {
  36. this.init();
  37. },
  38. methods: {
  39. init() {
  40. this.loading = true;
  41. if (this.type === 'model') {
  42. getProcessSetData(this.part.id).then(this.initSuccess);
  43. } else {
  44. getProcessData(this.part.id).then(this.initSuccess);
  45. }
  46. },
  47. initSuccess(res) {
  48. if (res.state) {
  49. this.list = res.data;
  50. }
  51. this.loading = false;
  52. },
  53. edit() {
  54. let data = this.$store.getters.processSet;
  55. this.itemId = data.id;
  56. switch (data.type) {
  57. case 'insert':
  58. this.visible = true;
  59. this.isUpdate = false;
  60. break;
  61. case 'update':
  62. this.visible = true;
  63. this.isUpdate = true;
  64. break;
  65. case 'delete':
  66. this.deleteDepartment();
  67. break;
  68. default:
  69. break;
  70. }
  71. },
  72. deleteDepartment() {
  73. this.$confirm('确定要删除该过程?', () => {
  74. if (this.type === 'model') {
  75. deleteProcessSetData(this.itemId).then(this.deleteSUccessFunc);
  76. } else {
  77. deleteProcessData(this.itemId).then(this.deleteSUccessFunc);
  78. }
  79. });
  80. },
  81. deleteSUccessFunc(res) {
  82. if (res.state) {
  83. this.$message.success('操作成功');
  84. this.init();
  85. }
  86. },
  87. callback(type) {
  88. this.visible = false;
  89. if (type === 'init') {
  90. this.init();
  91. this.$emit('callback', 'reloadKey');
  92. }
  93. }
  94. },
  95. computed: {
  96. ...mapGetters(['processSet'])
  97. },
  98. components: {
  99. processSetItem,
  100. processForm
  101. },
  102. watch: {
  103. processSet() {
  104. if (this.operationType === 'edit') this.edit();
  105. }
  106. },
  107. }
  108. </script>
  109. <style lang="scss">
  110. .process-set {
  111. padding: 15px;
  112. &.model {
  113. width: 100%;
  114. height: 100%;
  115. overflow-y: auto;
  116. }
  117. &.product {
  118. min-height: 300px;
  119. }
  120. .process-set-item {
  121. padding-left: 40px;
  122. position: relative;
  123. }
  124. .process-set-insert {
  125. font-size: 12px;
  126. color: $--color-primary;
  127. border: 1px solid $--color-primary;
  128. padding: 2px 5px;
  129. display: inline;
  130. border-radius: 3px;
  131. cursor: pointer;
  132. opacity: 0.8;
  133. }
  134. .process-item-title {
  135. padding: 5px 0;
  136. .label {
  137. font-weight: bold;
  138. color: $--color-text-primary;
  139. font-size: $--font-size-large;
  140. }
  141. .el-icon-edit-outline {
  142. margin-left: 10px;
  143. }
  144. .el-icon-delete,
  145. .el-icon-edit-outline {
  146. padding: 2px;
  147. cursor: pointer;
  148. }
  149. }
  150. .process-item-content {
  151. padding: 5px 0;
  152. }
  153. .process-set-state {
  154. width: 20px;
  155. height: 20px;
  156. border-radius: 50%;
  157. position: absolute;
  158. left: 7px;
  159. top: 6px;
  160. display: flex;
  161. align-items: center;
  162. justify-content: center;
  163. }
  164. .process-set-state-1 {
  165. width: 8px;
  166. height: 8px;
  167. border-radius: 50%;
  168. }
  169. .process-set-state-2 {
  170. width: 14px;
  171. height: 14px;
  172. border-radius: 50%;
  173. display: flex;
  174. align-items: center;
  175. justify-content: center;
  176. }
  177. .line {
  178. position: absolute;
  179. left: 16px;
  180. width: 2px;
  181. }
  182. .line-top {
  183. top: 0;
  184. height: 6px;
  185. }
  186. .line-bottom {
  187. top: 26px;
  188. bottom: 0;
  189. }
  190. .success {
  191. .process-set-state,
  192. .line {
  193. background: rgba(0, 180, 42, 0.4);
  194. }
  195. .process-set-state-1 {
  196. background: rgba(0, 180, 42, 1);
  197. }
  198. .process-set-state-2 {
  199. background: rgba(0, 180, 42, 0.6);
  200. }
  201. }
  202. .error {
  203. .process-set-state,
  204. .line {
  205. background: rgba(245, 63, 63, 0.4);
  206. }
  207. .process-set-state-1 {
  208. background: rgba(245, 63, 63, 1);
  209. }
  210. .process-set-state-2 {
  211. background: rgba(245, 63, 63, 0.6);
  212. }
  213. }
  214. .waiting {
  215. .process-set-state,
  216. .line {
  217. background: rgba(255, 125, 0, 0.4);
  218. }
  219. .process-set-state-1 {
  220. background: rgba(255, 125, 0, 1);
  221. }
  222. .process-set-state-2 {
  223. background: rgba(255, 125, 0, 0.6);
  224. }
  225. }
  226. .info {
  227. .process-set-state,
  228. .line {
  229. background: rgba(144, 157, 143, 0.4);
  230. }
  231. .process-set-state-1 {
  232. background: rgba(144, 157, 143, 1);
  233. }
  234. .process-set-state-2 {
  235. background: rgba(144, 157, 143, 0.6);
  236. }
  237. }
  238. }
  239. </style>