material-tech-note-change.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <template>
  2. <div>
  3. <div class="my-title">变更通知人设置</div>
  4. <!-- 表单 -->
  5. <el-form
  6. :model="dataForm"
  7. :rules="dataRule"
  8. ref="dataForm"
  9. label-width="auto"
  10. >
  11. <el-row class="my-row">
  12. <el-form-item label="通知接收人" prop="userIds">
  13. <user-components
  14. v-model="dataForm.userIds"
  15. :userIds.sync="dataForm.userIds"
  16. @change="userSelectedChanged"
  17. />
  18. </el-form-item>
  19. </el-row>
  20. </el-form>
  21. <span slot="footer" class="dialog-footer">
  22. <el-button @click="onChose">取消</el-button>
  23. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  24. </span>
  25. </div>
  26. </template>
  27. <script>
  28. import UserComponents from "../common/user-components";
  29. export default {
  30. name: "material-tech-note-change",
  31. components: {
  32. UserComponents,
  33. },
  34. data() {
  35. return {
  36. visible: false,
  37. dataForm: {
  38. userIds: [],
  39. },
  40. dataRule: {
  41. userIds: [
  42. { required: true, message: "请选择通知接收人", trigger: "change" },
  43. ],
  44. },
  45. };
  46. },
  47. created() {},
  48. methods: {
  49. onChose() {
  50. this.$emit("onChose");
  51. },
  52. async init() {
  53. this.dataForm = {};
  54. this.$http({
  55. url: this.$http.adornUrl(
  56. `/biz-service/pro-technology-option/noteChangeConfig`
  57. ),
  58. method: "get",
  59. }).then(({ data }) => {
  60. if (data && data.code === "200") {
  61. this.dataForm = {
  62. userIds: data.data,
  63. };
  64. }
  65. });
  66. this.visible = true;
  67. },
  68. validateField(type) {
  69. this.$refs.dataForm.validateField(type);
  70. },
  71. // 表单提交
  72. dataFormSubmit() {
  73. this.$refs["dataForm"].validate((valid) => {
  74. if (valid) {
  75. this.$http({
  76. url: this.$http.adornUrl(
  77. `/biz-service/pro-technology-option/noteChangeConfig`
  78. ),
  79. method: "post",
  80. data: this.dataForm.userIds,
  81. }).then(({ data }) => {
  82. if (data && data.code === "200") {
  83. this.$message({
  84. message: "操作成功",
  85. type: "success",
  86. duration: 1500,
  87. onClose: () => {
  88. this.onChose();
  89. },
  90. });
  91. } else {
  92. this.$message.error(data.msg);
  93. }
  94. });
  95. }
  96. });
  97. },
  98. userSelectedChanged(val) {
  99. this.dataForm.userIds = val;
  100. },
  101. },
  102. };
  103. </script>
  104. <style scoped></style>