DeductionShowDetailsForm.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div>
  3. <el-dialog
  4. :title="title"
  5. :close-on-click-modal="false"
  6. :visible.sync="visible">
  7. <el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''" :disabled="method==='view'"
  8. label-width="120px">
  9. <el-row :gutter="15">
  10. <el-col :span="12">
  11. <el-form-item label="年份" prop="yearOfEvaluation"
  12. :rules="[
  13. ]">
  14. <el-input readonly v-model="inputForm.yearOfEvaluation" placeholder="请填写年份" ></el-input>
  15. </el-form-item>
  16. </el-col>
  17. <el-col :span="12">
  18. <el-form-item label="名称" prop="unitName"
  19. :rules="[
  20. ]">
  21. <el-input readonly v-model="inputForm.unitName" placeholder="请填写名称" ></el-input>
  22. </el-form-item>
  23. </el-col>
  24. <el-col :span="12">
  25. <el-form-item label="扣分大类" prop="classId"
  26. :rules="[
  27. {required: true, message:'扣分大类不能为空', trigger:'blur'}
  28. ]">
  29. <el-select v-model="inputForm.classId" placeholder="请选择" @change="selectGoodsByGroupId($event)" style="width: 100%;">
  30. <el-option
  31. v-for="item in bigClass"
  32. :key="item.value"
  33. :label="item.label"
  34. :value="item.value">
  35. </el-option>
  36. </el-select>
  37. </el-form-item>
  38. </el-col>
  39. <el-col :span="12">
  40. <el-form-item label="扣分小类" prop="subClassId"
  41. :rules="[
  42. {required: true, message:'扣分小类不能为空', trigger:'blur'}
  43. ]">
  44. <el-select v-model="inputForm.subClassId" placeholder="请选择" @change="selectVeto($event)" style="width: 100%;">
  45. <el-option
  46. v-for="item in subClass"
  47. :key="item.value"
  48. :label="item.label"
  49. :value="item.value">
  50. </el-option>
  51. </el-select>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="12">
  55. <el-form-item v-if="inputForm.veto != 1" label="扣分" prop="deductPoints"
  56. :rules="[
  57. {required: true, message:'扣分分数不为空', trigger:'blur'},
  58. {validator: isNumberZero, trigger:'blur'}
  59. ]">
  60. <el-input type="number" v-model="inputForm.deductPoints" placeholder="请填写扣分" ></el-input>
  61. </el-form-item>
  62. </el-col>
  63. <el-col :span="12">
  64. <el-form-item label="扣分详情" prop="deductionDetails"
  65. :rules="[
  66. {required: true, message:'扣分详情不为空', trigger:'blur'},
  67. ]">
  68. <el-input type="textarea" resize="none" :autosize="{ minRows: 4, maxRows: 4 }" v-model="inputForm.deductionDetails" placeholder="请填写扣分详情" ></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="12">
  72. <el-form-item label="日期" prop="deductionDate"
  73. :rules="[
  74. {required: true, message:'扣分日期不为空', trigger:'blur'},
  75. ]">
  76. <el-date-picker
  77. style="width: 100%;"
  78. readonly
  79. v-model="inputForm.deductionDate"
  80. type="date"
  81. value-format="yyyy-MM-dd"
  82. placeholder="选择扣分日期">
  83. </el-date-picker>
  84. </el-form-item>
  85. </el-col>
  86. <el-col :span="12">
  87. <el-form-item v-if="veto == '1'" label="是否否决" prop="veto"
  88. :rules="[
  89. {required: true, message:'是否否决不能为空', trigger:'blur'},
  90. ]">
  91. <el-select v-model="inputForm.veto" placeholder="请选择" style="width: 100%;">
  92. <el-option
  93. v-for="item in options"
  94. :key="item.value"
  95. :label="item.label"
  96. :value="item.value">
  97. </el-option>
  98. </el-select>
  99. </el-form-item>
  100. </el-col>
  101. </el-row>
  102. </el-form>
  103. <span slot="footer" class="dialog-footer">
  104. <el-button @click="visible = false">关闭</el-button>
  105. <el-button type="primary" v-if="method != 'view'" @click="doSubmit()" v-noMoreClick>确定</el-button>
  106. </span>
  107. </el-dialog>
  108. </div>
  109. </template>
  110. <script>
  111. export default {
  112. data () {
  113. return {
  114. title: '',
  115. method: '',
  116. visible: false,
  117. loading: false,
  118. isNumberZero: (rule, value, callback) => {
  119. const reg = /^[+]?[1-9]+$/
  120. if (!reg.test(value)) {
  121. return callback(new Error('情输入正确的扣分分数'))
  122. }
  123. this.$http.get(`/database/datalink/dataSource/checkEnName?oldEnName=${this.inputForm.oldEnName}&enName=${value}`).then(({data}) => {
  124. if (!data.success) {
  125. return callback(new Error('连接英文名已存在!'))
  126. } else {
  127. return callback()
  128. }
  129. })
  130. },
  131. inputForm: {
  132. id: '',
  133. unitId: '',
  134. classId: '',
  135. subClassId: '',
  136. yearOfEvaluation: '',
  137. unitName: '',
  138. bigName: '',
  139. serialNumber: '',
  140. smallName: '',
  141. deductPoints: '',
  142. deductionDetails: '',
  143. deductionDate: '',
  144. veto: ''
  145. },
  146. bigClass: [],
  147. subClass: [],
  148. veto: '0',
  149. options: [ {
  150. value: '0',
  151. label: '否'
  152. }, {
  153. value: '1',
  154. label: '是'
  155. }]
  156. }
  157. },
  158. components: {
  159. },
  160. methods: {
  161. init (method, id) {
  162. this.method = method
  163. this.inputForm.id = id
  164. if (method === 'add') {
  165. this.title = `新建扣分详细`
  166. } else if (method === 'edit') {
  167. this.title = '修改'
  168. } else if (method === 'view') {
  169. this.title = '查看扣分详细'
  170. }
  171. this.visible = true
  172. this.loading = false
  173. this.$nextTick(() => {
  174. this.$refs.inputForm.resetFields()
  175. if (method === 'edit' || method === 'view') { // 修改或者查看
  176. this.loading = true
  177. this.$http({
  178. url: `/deductionShowDetails/deductionShowDetails/queryById?id=${this.inputForm.id}`,
  179. method: 'get'
  180. }).then(({data}) => {
  181. console.log(data)
  182. this.inputForm = this.recover(this.inputForm, data.deductionShowDetails)
  183. this.veto = data.deductionShowDetails.veto
  184. this.$http({
  185. url: `/deductiondetails/deductionDetails/getBigClass?id=0`,
  186. method: 'get'
  187. }).then(({data}) => {
  188. this.bigClass = data.bigClass
  189. this.loading = false
  190. this.$http({
  191. url: `/deductiondetails/deductionDetails/getSubClass?id=${this.inputForm.classId}`,
  192. method: 'get'
  193. }).then(({data}) => {
  194. this.subClass = data.subClass
  195. this.loading = false
  196. })
  197. })
  198. this.loading = false
  199. })
  200. }
  201. })
  202. },
  203. // 表单提交
  204. doSubmit () {
  205. this.$refs['inputForm'].validate((valid) => {
  206. if (valid) {
  207. this.loading = true
  208. this.$http({
  209. url: `/deductionShowDetails/deductionShowDetails/update`,
  210. method: 'post',
  211. data: this.inputForm
  212. }).then(({data}) => {
  213. if (data && data.success) {
  214. this.visible = false
  215. this.$message.success(data.msg)
  216. this.$emit('refreshDataList')
  217. }
  218. this.loading = false
  219. })
  220. }
  221. })
  222. },
  223. selectGoodsByGroupId (val) {
  224. this.$http({
  225. url: `/deductiondetails/deductionDetails/getSubClass?id=${this.inputForm.classId}`,
  226. method: 'get'
  227. }).then(({data}) => {
  228. console.log(data)
  229. this.subClass = data.subClass
  230. this.inputForm.subClassId = ''
  231. this.loading = false
  232. })
  233. },
  234. selectVeto (val) {
  235. console.log(val)
  236. this.$http({
  237. url: `/deductiondetails/deductionDetails/getVeto?id=${this.inputForm.subClassId}`,
  238. method: 'get'
  239. }).then(({data}) => {
  240. console.log(data)
  241. this.veto = data.veto
  242. this.inputForm.veto = '0'
  243. this.loading = false
  244. })
  245. }
  246. }
  247. }
  248. </script>