Edit.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. module.exports = {
  2. data() {
  3. return {
  4. container_data : {
  5. host: 'localhost',
  6. post: '8080',
  7. type: 'OTHER'
  8. },
  9. container_rules: {
  10. host : [{
  11. required: true,
  12. message : '请填写容器所在服务器地址!',
  13. trigger : 'blur'
  14. }],
  15. home : [{
  16. required: true,
  17. message : '请填写容器根目录!',
  18. trigger : 'blur'
  19. }],
  20. port: [{
  21. required: true,
  22. type: 'number',
  23. message : '端口不能为空!',
  24. trigger : 'blur'
  25. }],
  26. description: [{
  27. required: true,
  28. message : '描述不能为空!',
  29. trigger : 'blur'
  30. }]
  31. }
  32. }
  33. },
  34. methods: {
  35. save_container(ref) {
  36. this.$refs[ref].validate((valid) => {
  37. if (valid) {
  38. this.$$api_deployment_saveContainer(this[ref], data => {
  39. this.$message.success('保存成功');
  40. this.$router.push('/deployment/container/list');
  41. });
  42. }
  43. });
  44. },
  45. reset_artifact(ref) {
  46. this.$refs[ref].resetFields();
  47. },
  48. getView(){
  49. if (this.$route.query.id) {
  50. this.$$api_deployment_getContainer({
  51. id: this.$route.query.id
  52. }, (data) => {
  53. this.container_data = data.content;
  54. });
  55. } else{
  56. this.$delete(this.container_data, 'id');
  57. this.$refs.container_data.resetFields();
  58. }
  59. },
  60. onHomeFieldBlur(ref) {
  61. if ('CLUSTER' != this[ref].type) {
  62. this.$$api_deployment_checkContainer({
  63. path: this[ref].home
  64. }, (data) => {
  65. data.content.host = 'localhost';
  66. this.container_data = data.content;
  67. });
  68. }
  69. }
  70. },
  71. mounted() {
  72. this.getView();
  73. },
  74. watch: {
  75. $route(to, from){
  76. this.getView();
  77. }
  78. }
  79. }