InspectItemForm.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <j-form-container :disabled="formDisabled">
  4. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  5. <a-row>
  6. <!-- <a-col :span="24">
  7. <a-form-model-item label="巡检标准编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="itemcode">
  8. <a-input v-model="model.itemcode" placeholder="请输入巡检标准编号" ></a-input>
  9. </a-form-model-item>
  10. </a-col> -->
  11. <a-col :span="24">
  12. <a-form-model-item label="名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="itemname">
  13. <a-input v-model="model.itemname" placeholder="请输入名称" ></a-input>
  14. </a-form-model-item>
  15. </a-col>
  16. <a-col :span="24">
  17. <a-form-model-item label="巡检标准类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="classification">
  18. <j-dict-select-tag type="list" v-model="model.classification" dictCode="inspect_item_type" placeholder="请选择巡检标准类型" />
  19. </a-form-model-item>
  20. </a-col>
  21. <a-col :span="24" v-if="model.classification === '1'">
  22. <a-form-model-item label="设备类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipdefid">
  23. <!-- <a-input v-model="model.equipdefid" placeholder="请选择设备类型" ></a-input> -->
  24. <j-tree-select
  25. ref="treeSelect"
  26. placeholder="请选择设备类型"
  27. v-model="model.equipdefid"
  28. dict="tpm_equipment_tree,name,id"
  29. pidField="parentid"
  30. pidValue="0"
  31. hasChildField="has_child"
  32. >
  33. </j-tree-select>
  34. </a-form-model-item>
  35. </a-col>
  36. <!-- <a-col :span="24">
  37. <a-form-model-item label="标签(多个用逗号隔开)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tag">
  38. <a-input v-model="model.tag" placeholder="请输入标签(多个用逗号隔开)" ></a-input>
  39. </a-form-model-item>
  40. </a-col> -->
  41. <a-col :span="24">
  42. <a-form-model-item label="巡检标准" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="inspectionstandards">
  43. <a-input v-model="model.inspectionstandards" placeholder="请输入巡检标准"></a-input>
  44. </a-form-model-item>
  45. </a-col>
  46. <a-col :span="24">
  47. <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
  48. <!-- <a-input v-model="model.remark" placeholder="请输入备注"></a-input> -->
  49. <a-textarea v-model="model.remark" rows="3" placeholder="请输入备注" />
  50. </a-form-model-item>
  51. </a-col>
  52. </a-row>
  53. </a-form-model>
  54. </j-form-container>
  55. </a-spin>
  56. </template>
  57. <script>
  58. import { httpAction, getAction } from '@/api/manage'
  59. import { validateDuplicateValue } from '@/utils/util'
  60. export default {
  61. name: 'InspectItemForm',
  62. components: {
  63. },
  64. props: {
  65. //表单禁用
  66. disabled: {
  67. type: Boolean,
  68. default: false,
  69. required: false
  70. }
  71. },
  72. data () {
  73. return {
  74. model:{
  75. },
  76. labelCol: {
  77. xs: { span: 24 },
  78. sm: { span: 5 },
  79. },
  80. wrapperCol: {
  81. xs: { span: 24 },
  82. sm: { span: 16 },
  83. },
  84. confirmLoading: false,
  85. validatorRules: {
  86. itemname: [
  87. { required: true, message: '请输入巡检标准名称!'},
  88. ],
  89. equipdefid: [
  90. { required: true, message: '请选择设备!'},
  91. ],
  92. inspectionstandards: [
  93. { required: true, message: '请输入巡检标准!'},
  94. ],
  95. classification: [
  96. { required: true, message: '请选择巡检标准类型!'},
  97. ],
  98. },
  99. url: {
  100. add: "/cmmsInspectItem/cmmsInspectItem/add",
  101. edit: "/cmmsInspectItem/cmmsInspectItem/edit",
  102. queryById: "/cmmsInspectItem/cmmsInspectItem/queryById"
  103. }
  104. }
  105. },
  106. computed: {
  107. formDisabled(){
  108. return this.disabled
  109. },
  110. },
  111. created () {
  112. //备份model原始值
  113. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  114. },
  115. methods: {
  116. add () {
  117. this.edit(this.modelDefault);
  118. },
  119. edit (record) {
  120. this.model = Object.assign({}, record);
  121. this.visible = true;
  122. },
  123. submitForm () {
  124. const that = this;
  125. // 触发表单验证
  126. this.$refs.form.validate(valid => {
  127. if (valid) {
  128. that.confirmLoading = true;
  129. let httpurl = '';
  130. let method = '';
  131. if(!this.model.id){
  132. httpurl+=this.url.add;
  133. method = 'post';
  134. }else{
  135. httpurl+=this.url.edit;
  136. method = 'put';
  137. }
  138. httpAction(httpurl,this.model,method).then((res)=>{
  139. if(res.success){
  140. that.$message.success(res.message);
  141. that.$emit('ok');
  142. }else{
  143. that.$message.warning(res.message);
  144. }
  145. }).finally(() => {
  146. that.confirmLoading = false;
  147. })
  148. }
  149. })
  150. },
  151. }
  152. }
  153. </script>