dialog.editItem.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div class="rule-type">
  3. <el-dialog
  4. :title="!formData.id ? '新增检查项' : '编辑检查项'"
  5. :visible.sync="dialogVisible"
  6. width="60%"
  7. :show-close="true"
  8. @close="onHide"
  9. >
  10. <div>
  11. <div class="box">
  12. <p>履职项</p>
  13. <el-form
  14. ref="form"
  15. :model="formData"
  16. :rules="formDataRules"
  17. label-width="110px"
  18. >
  19. <el-form-item prop="name" label="履职项">
  20. <el-input
  21. v-model="formData.name"
  22. :maxlength="50"
  23. name="name"
  24. placeholder="请输入履职项"
  25. clearable
  26. />
  27. </el-form-item>
  28. </el-form>
  29. </div>
  30. <div class="box">
  31. <p>履职内容</p>
  32. <div style="margin-bottom: 10px">
  33. <el-button type="primary" @click="onAddPoint(-1)">新增</el-button>
  34. </div>
  35. <el-table :data="formData.pointDtoList" border style="width: 100%">
  36. <el-table-column prop="name" label="履职要点">
  37. </el-table-column>
  38. <el-table-column prop="areaName" label="履职区域">
  39. </el-table-column>
  40. <el-table-column label="操作" width="140">
  41. <template slot-scope="scope">
  42. <el-button
  43. type="text"
  44. size="small"
  45. @click="onEdit(scope.$index, scope.row)"
  46. >编辑</el-button
  47. >
  48. <k-btn-tip
  49. type="text"
  50. :tip="'确定删除该条履职内容?'"
  51. @click="delitem(scope.$index)"
  52. >删除</k-btn-tip
  53. >
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. </div>
  58. </div>
  59. <span slot="footer" class="dialog-footer">
  60. <el-button @click="dialogVisible = false">取 消</el-button>
  61. <el-button type="primary" @click="onSubmit()">保 存</el-button>
  62. </span>
  63. </el-dialog>
  64. <EditPoint ref="editDialog" @submit="onPointSubmit"></EditPoint>
  65. </div>
  66. </template>
  67. <script>
  68. import { mapState, mapMutations } from "vuex";
  69. import EditPoint from "./dialog.editPoint.vue";
  70. import { get, update } from "@/api/resumption/ruleManager.js";
  71. export default {
  72. data() {
  73. return {
  74. dialogVisible: false,
  75. formData: this.reset(),
  76. formDataRules:{
  77. name: [{ required: true, message: "请输入履职项" }],
  78. }
  79. };
  80. },
  81. props: {},
  82. watch: {},
  83. computed: {
  84. ...mapState([]),
  85. },
  86. methods: {
  87. ...mapMutations([]),
  88. reset() {
  89. return {
  90. id: null,
  91. nme: null,
  92. ruleId: null,
  93. pointDtoList: [],
  94. };
  95. },
  96. async show(id) {
  97. const data = id ? await get(id) : this.reset();
  98. this.formData = data;
  99. this.dialogVisible = true;
  100. },
  101. // 事件
  102. onHide() {
  103. this.formData = this.reset();
  104. },
  105. async onSubmit() {
  106. this.formData.ruleId = this.formruleID;
  107. await update(this.formData).then((v) => {
  108. console.log(v);
  109. this.formData = this.reset();
  110. this.dialogVisible = false;
  111. this.getlist();
  112. });
  113. },
  114. onclose() {
  115. this.dataVisible = false;
  116. },
  117. onEdit(index, row) {
  118. this.$refs.editDialog.show(index, row);
  119. },
  120. onPointSubmit(index, point) {
  121. if (index >= 0) {
  122. this.$set(this.formData.pointDtoList, i, point);
  123. } else {
  124. this.formData.pointDtoList.push(point);
  125. }
  126. },
  127. delitem(val) {
  128. this.formdetail.pointDtoList.splice(val, 1);
  129. },
  130. },
  131. mounted() {},
  132. components: { EditPoint },
  133. };
  134. </script>
  135. <style lang="scss">
  136. .brand_info {
  137. .el-form {
  138. width: 600px;
  139. padding-top: 40px;
  140. }
  141. }
  142. </style>