You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

521 lines
19 KiB

3 years ago
7 months ago
7 months ago
7 months ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
7 months ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div class="customer-css">
  3. <el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" width="960px" style="height: 662px;" class="customer-dialog">
  4. <el-form :inline="true" label-position="top" :model="pageData" :rules="rules" style="margin-left: 7px;margin-top: -5px;">
  5. <el-form-item label="BU" prop="bu" :rules="rules.bu">
  6. <el-select v-model="pageData.bu" placeholder="请选择" :disabled="modalDisableFlag" style="width: 150px">
  7. <el-option
  8. v-for = "i in userBuList"
  9. :key = "i.buNo"
  10. :label = "i.sitename"
  11. :value = "i.buNo">
  12. <span style="float: left;width: 100px">{{ i.sitename }}</span>
  13. <span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
  14. {{ i.buDesc }}
  15. </span>
  16. </el-option>
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="设备编码" prop="objectID" :rules="rules.objectIdType">
  20. <el-input v-model="pageData.objectID" style="width: 120px"></el-input>
  21. </el-form-item>
  22. <el-form-item label="设备名称" prop="objectDesc" :rules="rules.objectDesc" style="margin-left: -10px">
  23. <el-input v-model="pageData.objectDesc" style="width: 300px"></el-input>
  24. </el-form-item>
  25. <el-form-item label="序列号" style="margin-left: -10px">
  26. <el-input v-model="pageData.seqNo" style="width: 163px;"></el-input>
  27. </el-form-item>
  28. <el-form-item label="资产编号" style="margin-left: -10px">
  29. <el-input v-model="pageData.assetNo" style="width: 163px;"></el-input>
  30. </el-form-item>
  31. </el-form>
  32. <el-form :inline="true" label-position="top" :model="pageData" :rules="rules" style="margin-left: 7px">
  33. <el-form-item prop="locationID" :rules="rules.locationType">
  34. <span slot="label" @click="getBaseList(26)"><a herf="#">区域</a></span>
  35. <el-input v-model="pageData.locationID" style="width: 120px;"></el-input>
  36. <el-input v-model="pageData.locationName" disabled style="width: 330px"></el-input>
  37. </el-form-item>
  38. <el-form-item prop="familyID" :rules="rules.familyType">
  39. <span slot="label" @click="getBaseList(27)"><a herf="#">分类</a></span>
  40. <el-input v-model="pageData.familyID" style="width: 120px;" ></el-input>
  41. <el-input v-model="pageData.familyDesc" disabled style="width: 330px"></el-input>
  42. </el-form-item>
  43. </el-form>
  44. <el-form :inline="true" label-position="top" :model="pageData" :rules="rules" style="margin-left: 7px">
  45. <el-form-item prop="groupID" :rules="rules.groupType">
  46. <span slot="label" @click="getBaseList(28)"><a herf="#">分组</a></span>
  47. <el-input v-model="pageData.groupID" style="width: 120px;"></el-input>
  48. <el-input v-model="pageData.groupDesc" disabled style="width: 330px"></el-input>
  49. </el-form-item>
  50. <el-form-item>
  51. <span slot="label" @click="getBaseList(29)"><a herf="#">供应商</a></span>
  52. <el-input v-model="pageData.supplierID" style="width: 120px;"></el-input>
  53. <el-input v-model="pageData.supplierName" disabled style="width: 330px"></el-input>
  54. </el-form-item>
  55. </el-form>
  56. <el-form :inline="true" label-position="top" :model="pageData" style="margin-left: 7px">
  57. <el-form-item>
  58. <span slot="label" @click="getBaseList(30)"><a herf="#">制造商编码</a></span>
  59. <el-input v-model="pageData.manufacturerID" style="width: 120px;"></el-input>
  60. <el-input v-model="pageData.manufacturerName" disabled style="width: 330px"></el-input>
  61. </el-form-item>
  62. <el-form-item>
  63. <span slot="label" style="" @click="getBaseList(503)"><a herf="#">机台编码</a></span>
  64. <el-input v-model="pageData.resourceID" style="width: 120px;" ></el-input>
  65. <el-input v-model="pageData.resourceDesc" disabled style="width: 330px"></el-input>
  66. </el-form-item>
  67. </el-form>
  68. <el-form :inline="true" label-position="top" :model="pageData" :rules="rules" style="margin-left: 7px">
  69. <el-form-item prop="deptID" :rules="rules.deptType">
  70. <span slot="label" @click="getBaseList(204)"><a herf="#">所属部门编码</a></span>
  71. <el-input v-model="pageData.deptID" style="width: 120px"></el-input>
  72. <el-input v-model="pageData.deptName" disabled style="width: 330px"></el-input>
  73. </el-form-item>
  74. <el-form-item label="及时通知">
  75. <el-select multiple collapse-tags v-model="pageData.mesTypeList" style="width: 151px;">
  76. <el-option label="短信" value="A"></el-option>
  77. <el-option label="邮件" value="B"></el-option>
  78. <el-option label="随身机" value="C"></el-option>
  79. <el-option label="三色灯" value="D"></el-option>
  80. </el-select>
  81. </el-form-item>
  82. <el-form-item label="标准响应时长(m)">
  83. <el-input-number :controls="false" :step="0" min="0" v-model="pageData.standardResponseDuration" style="width: 137px;"></el-input-number>
  84. </el-form-item>
  85. <el-form-item label="超时响应推送时长(m)">
  86. <el-input-number :controls="false" :step="0" min="0" v-model="pageData.timeOutResponseDuration" style="width: 137px;"></el-input-number>
  87. </el-form-item>
  88. </el-form>
  89. <el-form :inline="true" label-position="top" :model="pageData" style="margin-left: 7px">
  90. <el-form-item label="在用" prop="active" :rules="rules.activeType">
  91. <el-select v-model="pageData.active" style="width: 120px;">
  92. <el-option label="是" value="Y"></el-option>
  93. <el-option label="否" value="N"></el-option>
  94. </el-select >
  95. </el-form-item>
  96. <el-form-item label=" " prop="publicFacilitiesFlag">
  97. <el-checkbox v-model="pageData.publicFacilitiesFlag" :true-label="'Y'" :false-label="'N'"
  98. style="margin-left: 10px;">公共设施
  99. </el-checkbox>
  100. </el-form-item>
  101. <el-form-item label="购入日期">
  102. <el-date-picker v-model="pageData.purchessDate" value-format="yyyy-MM-dd HH:mm:ss"
  103. style="width: 225px;"></el-date-picker>
  104. </el-form-item>
  105. <el-form-item label="循环时间(m)">
  106. <el-input-number :controls="false" :step="0" min="0" v-model="pageData.cycleTimeSend" style="width: 152px;"></el-input-number>
  107. </el-form-item>
  108. <el-form-item label="标准维修时长(m)">
  109. <el-input-number :controls="false" :step="0" min="0" v-model="pageData.standardMaintenanceDuration" style="width: 137px;"></el-input-number>
  110. </el-form-item>
  111. <el-form-item label="超时维修推送时长(m)">
  112. <el-input-number :controls="false" :step="0" min="0" v-model="pageData.timeOutMaintenanceDuration" style="width: 137px;"></el-input-number>
  113. </el-form-item>
  114. </el-form>
  115. <el-form :inline="true" label-position="top" :model="pageData" style="margin-left: 7px">
  116. <el-form-item label="备注" >
  117. <el-input
  118. type="textarea"
  119. v-model="pageData.assetRemark"
  120. :rows="3"
  121. resize='none'
  122. show-word-limit
  123. style="width: 921px;height: 60px">
  124. </el-input>
  125. </el-form-item>
  126. </el-form>
  127. <el-footer style="height:31px;margin-top: 50px;text-align:center">
  128. <el-button type="primary" @click="saveEamObject()">保存</el-button>
  129. <el-button type="primary" @click="visible = false">关闭</el-button>
  130. </el-footer>
  131. </el-dialog>
  132. <!--列表的组件-->
  133. <Chooselist ref="baseList" @getBaseData="getBaseData"></Chooselist>
  134. </div>
  135. </template>
  136. <script>
  137. import {
  138. insertEamObject,
  139. updateEamObject,
  140. } from '@/api/eam/com_eam_object_add_update.js'
  141. import {getSiteAndBuByUserName} from "@/api/eam/eam.js"
  142. /* 引入组件 */
  143. import Chooselist from '@/views/modules/common/Chooselist_eam';
  144. var functionId = 'C10000001';
  145. export default {
  146. data() {
  147. return {
  148. titleCon: '设备清单维护',
  149. visible: false,
  150. userId: this.$store.state.user.name,
  151. pageData: {
  152. site: '',
  153. bu: '',
  154. buNo: '',
  155. username: this.$store.state.user.name,
  156. objectID: '',
  157. objectDesc: '',
  158. locationID: '',
  159. locationName: '',
  160. familyID: '',
  161. familyDesc: '',
  162. groupID: '',
  163. groupDesc: '',
  164. supplierID: '',
  165. supplierName: '',
  166. manufacturerID: '',
  167. manufacturerName: '',
  168. resourceID: '',
  169. resourceDesc: '',
  170. seqNo: '',
  171. purchessDate: '',
  172. active: 'Y',
  173. publicFacilitiesFlag: 'Y',
  174. addFlag: 'Y',
  175. checkFlag: 'Y',
  176. updateBy:'',
  177. deptID: '',
  178. deptName: '',
  179. assetNo: '',
  180. assetRemark: '',
  181. standardMaintenanceDuration: '',
  182. timeOutMaintenanceDuration: '',
  183. standardResponseDuration: '',
  184. timeOutResponseDuration: '',
  185. cycleTimeSend: undefined,
  186. mesType: '',
  187. mesTypeList: []
  188. },
  189. dataListLoading: false,
  190. rules:{
  191. objectIdType:[
  192. {
  193. required: true,
  194. message: ' ',
  195. trigger: ['blur','change']
  196. }
  197. ],
  198. objectDesc: [
  199. {
  200. required: true,
  201. message: ' ',
  202. trigger: ['blur','change']
  203. }
  204. ],
  205. locationType:[
  206. {
  207. required: true,
  208. message: ' ',
  209. trigger: ['blur','change']
  210. }
  211. ],
  212. familyType:[
  213. {
  214. required: true,
  215. message: ' ',
  216. trigger: ['blur','change']
  217. }
  218. ],
  219. groupType:[
  220. {
  221. required: true,
  222. message: ' ',
  223. trigger: ['blur','change']
  224. }
  225. ],
  226. deptType:[
  227. {
  228. required: true,
  229. message: ' ',
  230. trigger: ['blur','change']
  231. }
  232. ],
  233. activeType:[
  234. {
  235. required: true,
  236. message: ' ',
  237. trigger: ['blur','change']
  238. }
  239. ],
  240. bu: [
  241. {
  242. required: true,
  243. message: ' ',
  244. trigger: ['blur','change']
  245. }
  246. ]
  247. },
  248. userBuList: [],
  249. modalDisableFlag: false,
  250. }
  251. },
  252. methods: {
  253. // 获取用户的bu
  254. getSiteAndBuByUserName () {
  255. let tempData = {
  256. username: this.$store.state.user.name,
  257. }
  258. getSiteAndBuByUserName(tempData).then(({data}) => {
  259. if (data.code === 0) {
  260. this.userBuList = data.rows
  261. }
  262. })
  263. },
  264. // 初始化组件的参数
  265. init (currentRow) {
  266. //初始化参数
  267. this.pageData = JSON.parse(JSON.stringify(currentRow))
  268. //打开页面
  269. this.visible = true
  270. //判断是否是新增
  271. if (this.pageData.addFlag === 'Y') {
  272. this.modalDisableFlag = false
  273. this.pageData.bu = this.userBuList[0].buNo
  274. } else {
  275. this.pageData.bu = this.pageData.site + '_' + this.pageData.buNo
  276. this.modalDisableFlag = true
  277. }
  278. //重置人员信息
  279. this.pageData.username = this.userId
  280. },
  281. // 保存标签自定义的信息
  282. saveEamObject () {
  283. if (this.pageData.bu === '' || this.pageData.bu == null) {
  284. this.$message.warning('请选择BU!')
  285. return
  286. }
  287. if (this.pageData.active == null || this.pageData.active === '') {
  288. this.$message.warning("请选择是否在用!");
  289. return false
  290. }
  291. if (this.pageData.objectID == null || this.pageData.objectID === '') {
  292. this.$message.warning("设备编码不能为空!");
  293. return false
  294. }
  295. if (this.pageData.objectDesc == null || this.pageData.objectDesc === '') {
  296. this.$message.warning("设备名称不能为空!");
  297. return false
  298. }
  299. if (this.pageData.locationID == null || this.pageData.locationID === '') {
  300. this.$message.warning("区域不能为空!");
  301. return false
  302. }
  303. if (this.pageData.groupID == null || this.pageData.groupID === '') {
  304. this.$message.warning("分组不能为空!");
  305. return false
  306. }
  307. if (this.pageData.familyID == null || this.pageData.familyID === '') {
  308. this.$message.warning("分类不能为空!");
  309. return false
  310. }
  311. if (this.pageData.deptID == null || this.pageData.deptID === '') {
  312. this.$message.warning("所属部门不能为空!");
  313. return false
  314. }
  315. this.pageData.mesType = this.pageData.mesTypeList.join(',')
  316. for (let i = 0; i < this.pageData.mesType.length; i++) {
  317. if(this.pageData.mesType[i] == 'D'){
  318. if(!this.pageData.cycleTimeSend || this.pageData.cycleTimeSend <= 0){
  319. this.$message.warning("三色灯选项需要添加循环时间或大于0!");
  320. return false
  321. }
  322. }
  323. }
  324. // 判断是否是新增标签自定义
  325. if (this.pageData.addFlag === 'Y') {
  326. this.insertEamObjectData()
  327. } else {
  328. this.updateEamObjectData()
  329. }
  330. },
  331. // 新增
  332. insertEamObjectData () {
  333. // if (this.pageData.site == '软标/RFID') {
  334. // this.pageData.site = '2'
  335. // }
  336. // if (this.pageData.site == '硬标') {
  337. // this.pageData.site = '3'
  338. // }
  339. // if (this.pageData.site == '通用设备') {
  340. // this.pageData.site = '4'
  341. // }
  342. insertEamObject(this.pageData).then(({data}) => {
  343. if (data.code === 200) {
  344. this.$message.success(data.msg)
  345. setTimeout(this.closeDialog(), 2000)
  346. } else {
  347. this.$message.error(data.msg)
  348. }
  349. })
  350. },
  351. // 修改
  352. updateEamObjectData () {
  353. // if (this.pageData.site == '软标/RFID'){
  354. // this.pageData.site = '2'
  355. // }
  356. // if (this.pageData.site == '硬标'){
  357. // this.pageData.site = '3'
  358. // }
  359. // if (this.pageData.site == '通用设备'){
  360. // this.pageData.site = '4'
  361. // }
  362. updateEamObject(this.pageData).then(({data}) => {
  363. if (data.code === 200) {
  364. this.$message.success(data.msg)
  365. setTimeout(this.closeDialog(), 2000);
  366. }else{
  367. this.$message.error(data.msg);
  368. }
  369. })
  370. },
  371. // 关闭modal
  372. closeDialog () {
  373. // 刷新报工的页面
  374. this.$emit('refreshPageTables')
  375. // 关闭当前的页面
  376. this.visible = false
  377. },
  378. // 列表方法的回调
  379. getBaseData (val) {
  380. if (this.tagNo === 26) {
  381. //设置参数
  382. this.pageData.locationID = val.LocationID;
  383. this.pageData.locationName = val.LocationName;
  384. } else if (this.tagNo === 27) {
  385. //设置参数
  386. this.pageData.familyID = val.FamilyID;
  387. this.$set(this.pageData,'familyDesc',val.FamilyDesc)
  388. } else if (this.tagNo === 28) {
  389. //设置参数
  390. this.pageData.groupID = val.GroupID;
  391. this.$set(this.pageData,'groupDesc',val.GroupDesc)
  392. } else if (this.tagNo === 29) {
  393. //设置参数
  394. this.pageData.supplierID = val.SupplierID;
  395. this.$set(this.pageData,'supplierName',val.SupplierName)
  396. } else if (this.tagNo === 30) {
  397. //设置参数
  398. this.pageData.manufacturerID = val.ManufacturerID;
  399. this.$set(this.pageData,'manufacturerName',val.ManufacturerName)
  400. } else if (this.tagNo === 503) {
  401. //设置参数
  402. this.pageData.resourceID = val.resource_id
  403. this.$set(this.pageData,'resourceDesc',val.resource_desc)
  404. } else if (this.tagNo === 204) {
  405. //设置参数
  406. this.pageData.deptID = val.department_id
  407. this.$set(this.pageData,'deptName',val.department_name)
  408. }
  409. },
  410. // 获取基础数据列表
  411. getBaseList (val) {
  412. this.tagNo = val
  413. this.$nextTick(() => {
  414. let strVal = ''
  415. let conSql = ''
  416. if (val === 26) {
  417. strVal = this.pageData.locationID
  418. if (this.pageData.bu === null || this.pageData.bu === '') {
  419. this.$message.warning("请选择BU!")
  420. return
  421. } else {
  422. conSql = " and bu_no = '" + this.pageData.bu.split('_')[1] + "'"
  423. this.$refs.baseList.init(val, strVal, conSql)
  424. }
  425. }else if (val === 27) {
  426. strVal = this.pageData.familyID
  427. if (this.pageData.bu === null || this.pageData.bu === '') {
  428. this.$message.warning("请选择BU!")
  429. return
  430. } else {
  431. conSql = " and bu_no = '" + this.pageData.bu.split('_')[1] + "'"
  432. this.$refs.baseList.init(val, strVal, conSql)
  433. }
  434. }else if (val === 28) {
  435. strVal = this.pageData.groupID
  436. if (this.pageData.bu === null || this.pageData.bu === '') {
  437. this.$message.warning("请选择BU!")
  438. return
  439. } else {
  440. conSql = " and bu_no = '" + this.pageData.bu.split('_')[1] + "'"
  441. this.$refs.baseList.init(val, strVal, conSql)
  442. }
  443. }else if (val === 29) {
  444. strVal = this.pageData.supplierID
  445. if (this.pageData.bu === null || this.pageData.bu === '') {
  446. this.$message.warning("请选择BU!")
  447. return
  448. } else {
  449. conSql = " and bu_no = '" + this.pageData.bu.split('_')[1] + "'"
  450. this.$refs.baseList.init(val, strVal, conSql)
  451. }
  452. }else if (val === 30) {
  453. strVal = this.pageData.manufacturerID
  454. if (this.pageData.bu === null || this.pageData.bu === '') {
  455. this.$message.warning("请选择BU!")
  456. return
  457. } else {
  458. conSql = " and bu_no = '" + this.pageData.bu.split('_')[1] + "'"
  459. this.$refs.baseList.init(val, strVal, conSql)
  460. }
  461. }else if (val === 503) {
  462. strVal = this.pageData.resourceID
  463. if (this.pageData.bu === null || this.pageData.bu === '') {
  464. this.$message.warning("请选择BU!")
  465. return
  466. } else {
  467. conSql = " and site = '" + this.pageData.bu.split('_')[0] + "'"
  468. this.$refs.baseList.init(val, strVal, conSql)
  469. }
  470. }else if (val === 204) {
  471. strVal = this.pageData.deptID
  472. if (this.pageData.bu === null || this.pageData.bu === '') {
  473. this.$message.warning("请选择BU!")
  474. return
  475. } else {
  476. conSql = " and bu_no = '" + this.pageData.bu.split('_')[1] + "'"
  477. this.$refs.baseList.init(val, strVal, conSql)
  478. }
  479. }
  480. })
  481. },
  482. },
  483. components: {
  484. Chooselist, /* 选择的组件 */
  485. },
  486. watch: {
  487. pageData: {
  488. deep: true,
  489. handler: function (newV, oldV) {
  490. this.pageData.objectID = this.pageData.objectID.toUpperCase();
  491. this.pageData.locationID = this.pageData.locationID.toUpperCase();
  492. this.pageData.familyID = this.pageData.familyID.toUpperCase();
  493. this.pageData.groupID = this.pageData.groupID.toUpperCase();
  494. this.pageData.supplierID = this.pageData.supplierID.toUpperCase();
  495. this.pageData.manufacturerID = this.pageData.manufacturerID.toUpperCase();
  496. }
  497. },
  498. },
  499. created() {
  500. // 获取用户的 site 和 bu
  501. this.getSiteAndBuByUserName()
  502. }
  503. }
  504. </script>
  505. <style scoped lang="scss">
  506. </style>