InspectContentForm.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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="contentcode">
  9. <a-input v-model="model.contentcode" 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="classification">
  14. <j-dict-select-tag type="radio" v-model="model.classification" dictCode="inspect_item_type" placeholder="请选择巡检类型" @input="inspectTypeChange()" />
  15. </a-form-model-item>
  16. </a-col>
  17. <a-col :span="12">
  18. <a-form-model-item label="巡检内容名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contentname">
  19. <a-input v-model="model.contentname" placeholder="请输入巡检内容名称" ></a-input>
  20. </a-form-model-item>
  21. </a-col>
  22. <a-col :span="12" v-if="model.classification === '1'">
  23. <a-form-model-item label="选择设备" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentid">
  24. <div class="u-flex select-equipment">
  25. <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" />
  26. <div class="u-flex-jac search-btn" @click="chooseEquipment">
  27. <a-icon type="search" style="color: #fff;font-size: 18px;" />
  28. </div>
  29. </div>
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :span="12">
  33. <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
  34. <j-dict-select-tag type="radio" v-model="model.status" dictCode="inspect_content_status" placeholder="请选择状态" />
  35. </a-form-model-item>
  36. </a-col>
  37. <a-col :span="12">
  38. <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
  39. <a-input v-model="model.remark" placeholder="请输入备注"></a-input>
  40. </a-form-model-item>
  41. </a-col>
  42. <!-- <j-popup v-model="model.jPopup" code="demo" field="name" orgFields="name" destFields="name" :multi="true"/> -->
  43. </a-row>
  44. <div class="cmms-dialog-item-title u-flex-jab">
  45. <div>设备巡检设置</div>
  46. <div @click="addInspectItem"><a-icon type="plus"/>巡检项</div>
  47. </div>
  48. <a-table
  49. ref="table"
  50. size="middle"
  51. :scroll="{x:true}"
  52. bordered
  53. rowKey="id"
  54. :columns="columns"
  55. :dataSource="model.cmmsInspectContentItemList"
  56. :pagination="false"
  57. class="j-table-force-nowrap">
  58. <!-- :loading="loading" -->
  59. </a-table>
  60. </a-form-model>
  61. <inspect-content-modal-add ref="addItemRef" :equipmentId="model.equipmentid" :selectData="model.cmmsInspectContentItemList" @ok="handleItemOk"></inspect-content-modal-add>
  62. </j-form-container>
  63. </a-spin>
  64. </template>
  65. <script>
  66. // import '@/assets/less/TableExpand.less'
  67. // import { mixinDevice } from '@/utils/mixin'
  68. // import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  69. import { httpAction, getAction } from '@/api/manage'
  70. import { validateDuplicateValue } from '@/utils/util'
  71. import InspectContentModalAdd from './InspectContentModalAdd.vue'
  72. export default {
  73. name: 'InspectContentForm',
  74. // mixins:[JeecgListMixin, mixinDevice],
  75. components: {
  76. InspectContentModalAdd
  77. },
  78. props: {
  79. //表单禁用
  80. disabled: {
  81. type: Boolean,
  82. default: false,
  83. required: false
  84. }
  85. },
  86. data () {
  87. return {
  88. model:{
  89. cmmsInspectContentItemList: []
  90. },
  91. labelCol: {
  92. xs: { span: 24 },
  93. sm: { span: 5 },
  94. },
  95. wrapperCol: {
  96. xs: { span: 24 },
  97. sm: { span: 16 },
  98. },
  99. confirmLoading: false,
  100. validatorRules: {
  101. contentname: [
  102. { required: true, message: '请输入巡检内容名称!'},
  103. ],
  104. equipmentid: [
  105. { required: true, message: '请选择设备!'},
  106. ],
  107. status: [
  108. { required: true, message: '请选择状态!'},
  109. ],
  110. },
  111. url: {
  112. add: "/cmmsInspectContent/cmmsInspectContent/add",
  113. edit: "/cmmsInspectContent/cmmsInspectContent/edit",
  114. queryById: "/cmmsInspectContent/cmmsInspectContent/queryById"
  115. },
  116. columns: [
  117. // {
  118. // title: '#',
  119. // dataIndex: '',
  120. // key:'rowIndex',
  121. // width:60,
  122. // align:"center",
  123. // customRender:function (t,r,index) {
  124. // return parseInt(index)+1;
  125. // }
  126. // },
  127. {
  128. title:'点检项编号',
  129. align:"center",
  130. dataIndex: 'itemcode'
  131. },
  132. {
  133. title:'点检项名称',
  134. align:"center",
  135. dataIndex: 'itemname'
  136. },
  137. {
  138. title:'标准',
  139. align:"center",
  140. dataIndex: 'inspectionstandards',
  141. },
  142. {
  143. title:'备注',
  144. align:"center",
  145. dataIndex: 'remark'
  146. }
  147. ],
  148. }
  149. },
  150. computed: {
  151. formDisabled(){
  152. return this.disabled
  153. },
  154. },
  155. created () {
  156. //备份model原始值
  157. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  158. },
  159. methods: {
  160. inspectTypeChange(){
  161. this.model.cmmsInspectContentItemList = []
  162. this.$refs.addItemRef.type = this.model.classification
  163. },
  164. chooseEquipment(){
  165. },
  166. addInspectItem(){
  167. if (this.model.classification === '1' && this.model.equipmentid == undefined) {
  168. this.$message.error("请先选择设备!");
  169. } else {
  170. this.$refs.addItemRef.add();
  171. this.$refs.addItemRef.title = "选择巡检项";
  172. }
  173. },
  174. add () {
  175. // this.edit(this.modelDefault);
  176. this.visible = true
  177. },
  178. edit (record) {
  179. this.visible = true;
  180. this.confirmLoading = true
  181. // this.model = Object.assign({}, record);
  182. getAction(this.url.queryById, {id: record.id}).then((res) => {
  183. this.model = res.result
  184. this.confirmLoading = false
  185. })
  186. },
  187. submitForm () {
  188. const that = this;
  189. // 触发表单验证
  190. this.$refs.form.validate(valid => {
  191. if (valid) {
  192. that.confirmLoading = true;
  193. let httpurl = '';
  194. let method = '';
  195. if(!this.model.id){
  196. httpurl+=this.url.add;
  197. method = 'post';
  198. }else{
  199. httpurl+=this.url.edit;
  200. method = 'put';
  201. }
  202. httpAction(httpurl,this.model,method).then((res)=>{
  203. if(res.success){
  204. that.$message.success(res.message);
  205. that.$emit('ok');
  206. }else{
  207. that.$message.warning(res.message);
  208. }
  209. }).finally(() => {
  210. that.confirmLoading = false;
  211. })
  212. }
  213. })
  214. },
  215. handleItemOk(data){
  216. console.log(data)
  217. this.model.cmmsInspectContentItemList = data;
  218. }
  219. }
  220. }
  221. </script>
  222. <style scoped>
  223. @import '~@/assets/less/uStyle.less';
  224. </style>
  225. <style lang="less" scoped>
  226. .select-equipment{
  227. /deep/ .ant-select-selection{
  228. border-top-right-radius: 0;
  229. border-bottom-right-radius: 0;
  230. border-right: none;
  231. }
  232. .search-btn{
  233. background-color: #1890FF;
  234. width: 50px;
  235. border-top-right-radius: 4px;
  236. border-bottom-right-radius: 4px;
  237. border: 1px solid #1890FF;
  238. cursor: pointer;
  239. }
  240. }
  241. // .select-equipment:focus .search-btn{
  242. // border-right-width: 1px !important;
  243. // outline: 0;
  244. // box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
  245. // }
  246. </style>