UpkeepPlanForm.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  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. <div style="height: 100%;width:100%;display: flex;">
  7. <div style="height: 100%;width:92%;">
  8. <a-row>
  9. <!-- <a-col :span="12">
  10. <a-form-model-item label="保养计划编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="plancode">
  11. <a-input v-model="model.plancode" placeholder="请输入保养计划编号" ></a-input>
  12. </a-form-model-item>
  13. </a-col> -->
  14. <a-col :span="12">
  15. <a-form-model-item label="计划名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="planname">
  16. <a-input v-model="model.planname" placeholder="请输入计划名称" ></a-input>
  17. </a-form-model-item>
  18. </a-col>
  19. <a-col :span="12">
  20. <a-form-model-item label="选择设备" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentid">
  21. <j-search-select-tag v-model="model.equipmentid" dict="tpm_equipment,equipmentname,id" style="width: 100%"/>
  22. <!-- <a-button type="primary" icon="search" /> -->
  23. </a-form-model-item>
  24. </a-col>
  25. <!-- <a-col :span="12">
  26. <a-form-model-item label="保养工作项目ID" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="upkeepprojid">
  27. <a-input v-model="model.upkeepprojid" placeholder="请输入保养工作项目ID" ></a-input>
  28. </a-form-model-item>
  29. </a-col>
  30. <a-col :span="12">
  31. <a-form-model-item label="工作项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectname">
  32. <a-input v-model="model.projectname" placeholder="请输入工作项目名称" ></a-input>
  33. </a-form-model-item>
  34. </a-col>
  35. <a-col :span="12">
  36. <a-form-model-item label="厂商名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="supplier">
  37. <a-input v-model="model.supplier" placeholder="请输入厂商名称" ></a-input>
  38. </a-form-model-item>
  39. </a-col>
  40. <a-col :span="12">
  41. <a-form-model-item label="厂商电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="suppliertel">
  42. <a-input v-model="model.suppliertel" placeholder="请输入厂商电话" ></a-input>
  43. </a-form-model-item>
  44. </a-col>
  45. <a-col :span="12">
  46. <a-form-model-item label="联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="linker">
  47. <a-input v-model="model.linker" placeholder="请输入联系人" ></a-input>
  48. </a-form-model-item>
  49. </a-col>
  50. <a-col :span="12">
  51. <a-form-model-item label="联系人电话" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="linkertel">
  52. <a-input v-model="model.linkertel" placeholder="请输入联系人电话" ></a-input>
  53. </a-form-model-item>
  54. </a-col>
  55. <a-col :span="12">
  56. <a-form-model-item label="描述" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="plandesc">
  57. <a-input v-model="model.plandesc" placeholder="请输入描述" ></a-input>
  58. </a-form-model-item>
  59. </a-col> -->
  60. <a-col :span="12">
  61. <a-form-model-item label="地点" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="address">
  62. <a-input v-model="model.address" placeholder="请输入地点" ></a-input>
  63. </a-form-model-item>
  64. </a-col>
  65. <a-col :span="12">
  66. <a-form-model-item label="负责人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="chargeruser">
  67. <j-dict-select-tag v-model="model.chargeruser" placeholder="请输入负责人" dictCode="sys_user,realname,id"/>
  68. </a-form-model-item>
  69. </a-col>
  70. <a-col :span="12">
  71. <a-form-model-item label="开始时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="begintime">
  72. <j-date placeholder="请选择开始时间" v-model="model.begintime" style="width: 100%" :show-time="true" date-format="YYYY-MM-DD HH:mm:ss"/>
  73. </a-form-model-item>
  74. </a-col>
  75. <a-col :span="12">
  76. <a-form-model-item label="提前通知" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="noticenum">
  77. <a-input-number v-model="model.noticenum" :min="1" placeholder="请输入提前通知时长" style="width: 40%" />
  78. <j-dict-select-tag v-model="model.noticetype" placeholder="时长单位" dictCode="plan_notice_unit" style="width: 30%"/>
  79. </a-form-model-item>
  80. </a-col>
  81. <!-- <a-col :span="12">
  82. <a-form-model-item label="通知单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="noticetype">
  83. <j-dict-select-tag v-model="model.noticetype" placeholder="请选择通知单位" dictCode="plan_notice_unit"/>
  84. </a-form-model-item>
  85. </a-col> -->
  86. <a-col :span="12">
  87. <a-form-model-item label="重复间隔" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="repeatnum">
  88. <a-input-number v-model="model.repeatnum" :min="1" placeholder="请输入重复间隔" style="width: 40%" />
  89. <j-dict-select-tag v-model="model.repeattype" placeholder="间隔单位" dictCode="plan_cycle_unit" style="width: 30%" />
  90. </a-form-model-item>
  91. </a-col>
  92. <!-- <a-col :span="12">
  93. <a-form-model-item label="间隔单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="repeattype">
  94. <j-dict-select-tag v-model="model.repeattype" placeholder="请选择间隔单位" dictCode="plan_cycle_unit"/>
  95. </a-form-model-item>
  96. </a-col> -->
  97. <!-- <a-col :span="12">
  98. <a-form-model-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="status">
  99. <a-input v-model="model.status" placeholder="请输入状态(0启用 1停用)" ></a-input>
  100. </a-form-model-item>
  101. </a-col> -->
  102. <!-- <a-col :span="12">
  103. <a-form-model-item label="下次执行时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nexttime">
  104. <j-date placeholder="请选择下次执行时间" v-model="model.nexttime" style="width: 100%" />
  105. </a-form-model-item>
  106. </a-col>
  107. <a-col :span="12">
  108. <a-form-model-item label="下次通知时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="noticetime">
  109. <j-date placeholder="请选择下次通知时间" v-model="model.noticetime" style="width: 100%" />
  110. </a-form-model-item>
  111. </a-col> -->
  112. <!-- <a-col :span="12">
  113. <a-form-model-item label="是否已通知:是/否" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ifnotice">
  114. <a-input v-model="model.ifnotice" placeholder="请输入是否已通知:是/否" ></a-input>
  115. </a-form-model-item>
  116. </a-col> -->
  117. <a-col :span="12">
  118. <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
  119. <a-textarea v-model="model.remark" placeholder="请输入备注" :auto-size="{ minRows: 2, maxRows: 2 }"></a-textarea>
  120. </a-form-model-item>
  121. </a-col>
  122. </a-row>
  123. </div>
  124. <div style="height: 100%;width:8%;padding-top:0.3%;">
  125. <a-button type="primary" icon="search" />
  126. </div>
  127. </div>
  128. <div class="cmms-dialog-item-title u-flex-jab">
  129. <div>设备保养设置</div>
  130. <div>
  131. <a-button @click="handleAddUpkeepItem" type="link" icon="plus">保养项</a-button>
  132. </div>
  133. </div>
  134. <a-table
  135. ref="table"
  136. size="middle"
  137. :scroll="{x:true}"
  138. bordered
  139. rowKey="id"
  140. :columns="columns"
  141. :dataSource="model.cmmsUpkeepItemDtoList"
  142. :pagination="false"
  143. class="j-table-force-nowrap">
  144. </a-table>
  145. <upkeep-plan-modal-add ref="modalForm" @ok="modalFormOk" :modelForm="model" :dataList="model.cmmsUpkeepItemDtoList" @customEvent="handleCustomEvent"></upkeep-plan-modal-add>
  146. </a-form-model>
  147. </j-form-container>
  148. </a-spin>
  149. </template>
  150. <script>
  151. import { httpAction, getAction } from '@/api/manage'
  152. import { validateDuplicateValue } from '@/utils/util'
  153. import { mixinDevice } from '@/utils/mixin'
  154. import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  155. import UpkeepPlanModalAdd from './UpkeepPlanModalAdd.vue'
  156. export default {
  157. name: 'UpkeepPlanForm',
  158. mixins:[JeecgListMixin, mixinDevice],
  159. components: {
  160. UpkeepPlanModalAdd
  161. },
  162. props: {
  163. //表单禁用
  164. disabled: {
  165. type: Boolean,
  166. default: false,
  167. required: false
  168. }
  169. },
  170. data () {
  171. return {
  172. model:{
  173. noticetype: '天',
  174. repeattype: '天',
  175. cmmsUpkeepItemDtoList: []
  176. },
  177. labelCol: {
  178. xs: { span: 24 },
  179. sm: { span: 6 },
  180. },
  181. wrapperCol: {
  182. xs: { span: 24 },
  183. sm: { span: 18 },
  184. },
  185. confirmLoading: false,
  186. validatorRules: {
  187. planname: [
  188. { required: true, message: '请输入保养计划名称!'},
  189. ],
  190. equipmentid: [
  191. { required: true, message: '请选择设备!'},
  192. ],
  193. address: [
  194. { required: true, message: '请输入地点!'},
  195. ],
  196. chargeruser: [
  197. { required: true, message: '请输入负责人!'},
  198. ],
  199. begintime: [
  200. { required: true, message: '请选择开始时间!'},
  201. ],
  202. noticenum: [
  203. { required: true, message: '请输入提前通知时长!'},
  204. ],
  205. repeatnum: [
  206. { required: true, message: '请输入重复间隔!'},
  207. ],
  208. },
  209. url: {
  210. list: "/cmmsSpotcheckItem/cmmsSpotcheckItem/listbyequipmentid/{equipmentid}",
  211. add: "/cmmsUpkeepPlan/cmmsUpkeepPlan/add",
  212. edit: "/cmmsUpkeepPlan/cmmsUpkeepPlan/edit",
  213. queryById: "/cmmsUpkeepPlan/cmmsUpkeepPlan/queryById"
  214. },
  215. columns: [
  216. {
  217. title:'保养项ID',
  218. align:"center",
  219. dataIndex: 'id'
  220. },
  221. {
  222. title:'保养项名称',
  223. align:"center",
  224. dataIndex: 'itemname'
  225. },
  226. // {
  227. // title:'设备类型',
  228. // align:"center",
  229. // dataIndex: 'equiptypeName'
  230. // },
  231. {
  232. title:'保养项编号',
  233. align:"center",
  234. dataIndex: 'itemcode'
  235. },
  236. {
  237. title:'保养项标准',
  238. align:"center",
  239. dataIndex: 'itemcontent'
  240. },
  241. {
  242. title:'备注',
  243. align:"center",
  244. dataIndex: 'remark'
  245. },
  246. ],
  247. }
  248. },
  249. computed: {
  250. formDisabled(){
  251. return this.disabled
  252. },
  253. },
  254. created () {
  255. //备份model原始值
  256. this.modelDefault = JSON.parse(JSON.stringify(this.model));
  257. },
  258. methods: {
  259. add () {
  260. // this.edit(this.modelDefault);
  261. this.model = Object.assign({}, this.modelDefault);
  262. this.visible = true;
  263. },
  264. edit (record) {
  265. // this.model = Object.assign({}, record);
  266. getAction(this.url.queryById, record).then((res) => {
  267. console.log(88,res)
  268. this.model = res.result
  269. // this.model.cmmsUpkeepItemDtoList = this.model.cmmsUpkeepItemDtoList.map((res) => {
  270. // return {
  271. // id: id,
  272. // itemcode: res.itemcode,
  273. // itemname: res.itemname,
  274. // itemcontent: res.itemcontent,
  275. // remark: res.remark
  276. // }
  277. // })
  278. })
  279. this.visible = true;
  280. },
  281. submitForm () {
  282. const that = this;
  283. // 触发表单验证
  284. this.$refs.form.validate(valid => {
  285. if (valid) {
  286. that.confirmLoading = true;
  287. let httpurl = '';
  288. let method = '';
  289. if(!this.model.id){
  290. httpurl+=this.url.add;
  291. method = 'post';
  292. // 默认状态是禁用
  293. this.model.status = 1
  294. this.model.cmmsUpkeepItemDtoList = this.model.cmmsUpkeepItemDtoList.map((res) => {
  295. return {
  296. id: res.id
  297. }
  298. })
  299. }else{
  300. httpurl+=this.url.edit;
  301. method = 'put';
  302. this.model.cmmsUpkeepItemDtoList = this.model.cmmsUpkeepItemDtoList.map((res) => {
  303. return {
  304. id: res.id
  305. }
  306. })
  307. }
  308. console.log(999,this.model)
  309. httpAction(httpurl,this.model,method).then((res)=>{
  310. if(res.success){
  311. that.$message.success(res.message);
  312. that.$emit('ok');
  313. }else{
  314. that.$message.warning(res.message);
  315. }
  316. }).finally(() => {
  317. that.confirmLoading = false;
  318. })
  319. }
  320. })
  321. },
  322. // 通过已选设备获取保养项列表
  323. handleAddUpkeepItem(){
  324. console.log(this.model.equipmentid)
  325. if (this.model.equipmentid == undefined) {
  326. this.$message.error("请先选择设备!");
  327. } else {
  328. this.$refs.modalForm.add();
  329. this.$refs.modalForm.title = "选择保养项";
  330. }
  331. },
  332. // 处理子组件传过来的数据
  333. handleCustomEvent(data) {
  334. // 处理从子组件传递过来的数据
  335. console.log("子组件传过来的数据:", data);
  336. this.model.cmmsUpkeepItemDtoList = data;
  337. }
  338. }
  339. }
  340. </script>
  341. <style scoped>
  342. @import "~@/assets/less/uStyle.less";
  343. </style>