InspectLineForm.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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="linecode">
  9. <a-input v-model="model.linecode" 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="linename">
  14. <a-input v-model="model.linename" 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="remark">
  19. <a-input v-model="model.remark" 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="addInspectSpot"><a-icon type="plus"/>巡检点</div>
  26. </div>
  27. <a-table
  28. ref="table"
  29. size="middle"
  30. bordered
  31. rowKey="id"
  32. :columns="columns"
  33. :dataSource="model.inspectSpotList"
  34. :pagination="false"
  35. class="j-table-force-nowrap">
  36. <div slot="expandedRowRender" slot-scope="record">
  37. <a-table
  38. ref="table"
  39. size="middle"
  40. bordered
  41. rowKey="id"
  42. :columns="innerColumns"
  43. :dataSource="record.inspectContentList"
  44. :pagination="false"
  45. class="j-table-force-nowrap">
  46. </a-table>
  47. </div>
  48. </a-table>
  49. </a-form-model>
  50. <inspect-line-modal-add ref="addSpotRef" :selectData="model.inspectSpotList" @ok="handleOk"></inspect-line-modal-add>
  51. </j-form-container>
  52. </a-spin>
  53. </template>
  54. <script>
  55. import { httpAction, getAction } from '@/api/manage'
  56. import { validateDuplicateValue } from '@/utils/util'
  57. import InspectLineModalAdd from './InspectLineModalAdd.vue'
  58. export default {
  59. name: 'InspectLineForm',
  60. components: {
  61. InspectLineModalAdd,
  62. },
  63. props: {
  64. //表单禁用
  65. disabled: {
  66. type: Boolean,
  67. default: false,
  68. required: false
  69. }
  70. },
  71. data () {
  72. return {
  73. model:{
  74. inspectSpotList: []
  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. },
  87. url: {
  88. add: "/cmmsInspectLine/cmmsInspectLine/add",
  89. edit: "/cmmsInspectLine/cmmsInspectLine/edit",
  90. queryById: "/cmmsInspectLine/cmmsInspectLine/queryById"
  91. },
  92. columns: [
  93. // {
  94. // title: '',
  95. // dataIndex: '',
  96. // key:'rowIndex',
  97. // width:60,
  98. // align:"center",
  99. // customRender:function (t,r,index) {
  100. // return parseInt(index)+1;
  101. // }
  102. // },
  103. {
  104. title:'巡检点编号',
  105. align:"center",
  106. dataIndex: 'contentcode'
  107. },
  108. {
  109. title:'巡检点名称',
  110. align:"center",
  111. dataIndex: 'contentname'
  112. },
  113. {
  114. title:'备注',
  115. align:"center",
  116. dataIndex: 'remark'
  117. },
  118. ],
  119. innerColumns: [
  120. // {
  121. // title: '#',
  122. // dataIndex: '',
  123. // key:'rowIndex',
  124. // width:60,
  125. // align:"center",
  126. // customRender:function (t,r,index) {
  127. // return parseInt(index)+1;
  128. // }
  129. // },
  130. {
  131. title:'巡检项目编号',
  132. align:"center",
  133. dataIndex: 'contentcode'
  134. },
  135. {
  136. title:'巡检项目名称',
  137. align:"center",
  138. dataIndex: 'contentname'
  139. },
  140. {
  141. title:'巡检项目类型',
  142. align:"center",
  143. dataIndex: 'itemname'
  144. },
  145. {
  146. title:'巡检设备',
  147. align:"center",
  148. dataIndex: 'equipmentname'
  149. },
  150. // {
  151. // title:'标准',
  152. // align:"center",
  153. // dataIndex: 'inspectionstandards',
  154. // },
  155. {
  156. title:'备注',
  157. align:"center",
  158. dataIndex: 'remark'
  159. }
  160. ],
  161. }
  162. },
  163. computed: {
  164. formDisabled(){
  165. return this.disabled
  166. },
  167. },
  168. created () {
  169. //备份model原始值
  170. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  171. },
  172. methods: {
  173. add () {
  174. this.edit(this.modelDefault);
  175. },
  176. addInspectSpot(){
  177. this.$refs.addSpotRef.add();
  178. this.$refs.addSpotRef.title = "选择巡检点";
  179. },
  180. edit (record) {
  181. this.model = Object.assign({}, record);
  182. this.visible = true;
  183. },
  184. submitForm () {
  185. const that = this;
  186. // 触发表单验证
  187. this.$refs.form.validate(valid => {
  188. if (valid) {
  189. that.confirmLoading = true;
  190. let httpurl = '';
  191. let method = '';
  192. if(!this.model.id){
  193. httpurl+=this.url.add;
  194. method = 'post';
  195. }else{
  196. httpurl+=this.url.edit;
  197. method = 'put';
  198. }
  199. httpAction(httpurl,this.model,method).then((res)=>{
  200. if(res.success){
  201. that.$message.success(res.message);
  202. that.$emit('ok');
  203. }else{
  204. that.$message.warning(res.message);
  205. }
  206. }).finally(() => {
  207. that.confirmLoading = false;
  208. })
  209. }
  210. })
  211. },
  212. handleOk(data){
  213. console.log(data)
  214. data.map(res=>{
  215. })
  216. this.model.inspectSpotList = data;
  217. },
  218. }
  219. }
  220. </script>
  221. <style scoped>
  222. @import '~@/assets/less/uStyle.less';
  223. </style>