InspectLineForm.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. <div class="cmms-dialog-item-title">巡检路线基本信息</div>
  6. <a-row>
  7. <a-col :span="24">
  8. <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
  9. <a-input v-model="model.remark" placeholder="请输入备注" ></a-input>
  10. </a-form-model-item>
  11. </a-col>
  12. <a-col :span="24">
  13. <a-form-model-item label="巡检路线编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="linecode">
  14. <a-input v-model="model.linecode" placeholder="请输入巡检路线编号" ></a-input>
  15. </a-form-model-item>
  16. </a-col>
  17. <a-col :span="24">
  18. <a-form-model-item label="巡检路线名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="linename">
  19. <a-input v-model="model.linename" placeholder="请输入巡检路线名称" ></a-input>
  20. </a-form-model-item>
  21. </a-col>
  22. </a-row>
  23. <div class="cmms-dialog-item-title u-flex-jab">
  24. <div>巡检项目设置</div>
  25. <div @click="addInspectContent"><a-icon type="plus"/>巡检项目</div>
  26. </div>
  27. </a-form-model>
  28. <inspect-line-modal-add ref="addSpotRef" :equipmentId="model.equipmentid" :selectData="model.cmmsInspectSpotItemList" @ok="handleOk"></inspect-line-modal-add>
  29. </j-form-container>
  30. </a-spin>
  31. </template>
  32. <script>
  33. import { httpAction, getAction } from '@/api/manage'
  34. import { validateDuplicateValue } from '@/utils/util'
  35. import InspectLineModalAdd from './InspectLineModalAdd.vue'
  36. export default {
  37. name: 'InspectLineForm',
  38. components: {
  39. InspectLineModalAdd,
  40. },
  41. props: {
  42. //表单禁用
  43. disabled: {
  44. type: Boolean,
  45. default: false,
  46. required: false
  47. }
  48. },
  49. data () {
  50. return {
  51. model:{
  52. },
  53. labelCol: {
  54. xs: { span: 24 },
  55. sm: { span: 5 },
  56. },
  57. wrapperCol: {
  58. xs: { span: 24 },
  59. sm: { span: 16 },
  60. },
  61. confirmLoading: false,
  62. validatorRules: {
  63. },
  64. url: {
  65. add: "/cmmsInspectLine/cmmsInspectLine/add",
  66. edit: "/cmmsInspectLine/cmmsInspectLine/edit",
  67. queryById: "/cmmsInspectLine/cmmsInspectLine/queryById"
  68. }
  69. }
  70. },
  71. computed: {
  72. formDisabled(){
  73. return this.disabled
  74. },
  75. },
  76. created () {
  77. //备份model原始值
  78. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  79. },
  80. methods: {
  81. add () {
  82. this.edit(this.modelDefault);
  83. },
  84. addInspectContent(){
  85. this.$refs.addSpotRef.add();
  86. this.$refs.addSpotRef.title = "选择巡检点";
  87. },
  88. edit (record) {
  89. this.model = Object.assign({}, record);
  90. this.visible = true;
  91. },
  92. submitForm () {
  93. const that = this;
  94. // 触发表单验证
  95. this.$refs.form.validate(valid => {
  96. if (valid) {
  97. that.confirmLoading = true;
  98. let httpurl = '';
  99. let method = '';
  100. if(!this.model.id){
  101. httpurl+=this.url.add;
  102. method = 'post';
  103. }else{
  104. httpurl+=this.url.edit;
  105. method = 'put';
  106. }
  107. httpAction(httpurl,this.model,method).then((res)=>{
  108. if(res.success){
  109. that.$message.success(res.message);
  110. that.$emit('ok');
  111. }else{
  112. that.$message.warning(res.message);
  113. }
  114. }).finally(() => {
  115. that.confirmLoading = false;
  116. })
  117. }
  118. })
  119. },
  120. }
  121. }
  122. </script>
  123. <style scoped>
  124. @import '~@/assets/less/uStyle.less';
  125. </style>