阅行客电子档案
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

188 lines
5.6 KiB

2 years ago
  1. <template>
  2. <!--批量修改-->
  3. <el-dialog class="upload-dialog" title="批量修改" :close-on-click-modal="false" :modal-append-to-body="false" append-to-body :visible.sync="bulkEditingVisible">
  4. <div class="setting-dialog">
  5. <div class="bulk-editing-container">
  6. <el-form ref="editForm" :model="editForm" :rules="editRules" label-width="100px">
  7. <el-form-item label="修改字段" prop="fieldItem">
  8. <el-select v-model="editForm.fieldItem" placeholder="请选择" style="width: 360px;">
  9. <el-option
  10. v-for="item in fieldItemOptions"
  11. :key="item.value"
  12. :label="item.label"
  13. :value="item.value"
  14. />
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="修改方式" prop="type">
  18. <el-select v-model="editForm.type" placeholder="请选择" style="width: 360px;">
  19. <el-option
  20. v-for="item in editTypeOptions"
  21. :key="item.value"
  22. :label="item.label"
  23. :value="item.value"
  24. />
  25. </el-select>
  26. </el-form-item>
  27. <el-form-item v-if="editForm.type === '替换'" label="查询内容" prop="content">
  28. <el-input v-model="editForm.queryContent" style="width: 360px;" />
  29. </el-form-item>
  30. <el-form-item label="更新内容" prop="content">
  31. <el-input v-if="editForm.fieldItem !== '2' && editForm.fieldItem !== '3'" v-model="editForm.content" style="width: 360px;" />
  32. <el-select v-if="editForm.fieldItem === '2'" v-model="editForm.content" placeholder="请选择" style="width: 360px;">
  33. <el-option
  34. v-for="item in fieldOptions"
  35. :key="item.value"
  36. :label="item.label"
  37. :value="item.value"
  38. />
  39. </el-select>
  40. <el-date-picker
  41. v-if="editForm.fieldItem === '3'"
  42. v-model="editForm.content"
  43. type="date"
  44. placeholder="选择日期"
  45. style="width: 360px;"
  46. />
  47. </el-form-item>
  48. </el-form>
  49. </div>
  50. <div slot="footer" class="dialog-footer">
  51. <el-button type="text" @click="bulkEditingVisible = false">取消</el-button>
  52. <el-button type="primary" @click.native="onSubmitBlukEditing('editForm')">确定</el-button>
  53. </div>
  54. </div>
  55. </el-dialog>
  56. </template>
  57. <script>
  58. export default {
  59. name: 'BlukEditing',
  60. components: { },
  61. mixins: [],
  62. data() {
  63. return {
  64. // 批量修改
  65. bulkEditingVisible: false,
  66. editForm: {
  67. fieldItem: '',
  68. type: '填充',
  69. queryContent: '',
  70. content: ''
  71. },
  72. fieldItemOptions: [
  73. {
  74. value: '1',
  75. label: '非字典项&&文本'
  76. },
  77. {
  78. value: '2',
  79. label: '字典项'
  80. },
  81. {
  82. value: '3',
  83. label: '日期'
  84. },
  85. {
  86. value: '4',
  87. label: '数字'
  88. }
  89. ],
  90. editTypeOptions: [],
  91. fieldOptions: [
  92. {
  93. value: '字典项1',
  94. label: '字典项1'
  95. }
  96. ]
  97. }
  98. },
  99. computed: {
  100. editRules() {
  101. const validateRule = {
  102. fieldItem: [
  103. { required: true, message: '请选择修改字段', trigger: 'change' }
  104. ],
  105. type: [
  106. { required: true, message: '请选择修改方式', trigger: 'change' }
  107. ],
  108. queryContent: [
  109. { required: true, message: '请输入', trigger: 'blur' }
  110. ],
  111. content: [
  112. { required: true }
  113. ]
  114. }
  115. if (this.editForm.fieldItem === '2') {
  116. this.$set(validateRule, 'content', [
  117. { required: true, message: '请选择需更新内容得字典项', trigger: 'change' }
  118. ])
  119. } else if (this.editForm.fieldItem === '3') {
  120. this.$set(validateRule, 'content', [
  121. { type: 'date', required: true, message: '请选择日期', trigger: 'change' }
  122. ])
  123. } else {
  124. this.$set(validateRule, 'content', [
  125. { required: true, message: '请输入更新内容', trigger: 'blur' }
  126. ])
  127. }
  128. return validateRule
  129. }
  130. },
  131. watch: {
  132. 'editForm.fieldItem'(newVal) {
  133. this.$refs.editForm.clearValidate()
  134. this.editForm.content = ''
  135. this.editForm.type = '填充'
  136. if (newVal === '1') {
  137. this.editTypeOptions = [{
  138. value: '填充',
  139. label: '填充'
  140. },
  141. {
  142. value: '替换',
  143. label: '替换'
  144. }]
  145. } else if (newVal === '2' || newVal === '3') {
  146. this.editTypeOptions = [{
  147. value: '填充',
  148. label: '填充'
  149. }]
  150. } else if (newVal === '4') {
  151. this.editTypeOptions = [{
  152. value: '填充',
  153. label: '填充'
  154. },
  155. {
  156. value: '替换',
  157. label: '替换'
  158. },
  159. {
  160. value: '增加',
  161. label: '增加'
  162. },
  163. {
  164. value: '减少',
  165. label: '减少'
  166. }]
  167. }
  168. }
  169. },
  170. methods: {
  171. onSubmitBlukEditing(formName) {
  172. this.$refs[formName].validate((valid) => {
  173. if (valid) {
  174. this.$message('submit!')
  175. this.bulkEditingVisible = false
  176. } else {
  177. console.log('error submit!!')
  178. return false
  179. }
  180. })
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang='scss' scoped>
  186. </style>