SpotcheckItemForm.vue 5.1 KB

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