batchDialog.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. <template>
  2. <el-dialog
  3. title="批量维护信息点"
  4. :visible.sync="batchDialog"
  5. class="batchContainer"
  6. >
  7. <el-steps
  8. :active="active"
  9. align-center
  10. >
  11. <el-step
  12. @click.native="active = 0"
  13. description="填写需维护的信息点"
  14. />
  15. <el-step
  16. @click.native="active = 1"
  17. description="选择批量维护的对象实例"
  18. />
  19. </el-steps>
  20. <hr>
  21. <div
  22. v-show="active === 0"
  23. style="overflow: hidden"
  24. >
  25. <section>
  26. <p class="text-message">维护只有单值的信息点</p>
  27. <span class="small">请选择需维护的信息点</span>
  28. <el-checkbox
  29. :indeterminate="isIndeterminate"
  30. v-model="checkAll"
  31. @change="handleCheckChange"
  32. >
  33. 全部选择
  34. </el-checkbox>
  35. <div style="margin: 15px "></div>
  36. <el-checkbox-group
  37. v-model="checkedCities"
  38. @change="handleCheckedCitiesChange"
  39. >
  40. <el-checkbox
  41. v-for="(city,index) in newFirm"
  42. :label="city"
  43. :key="index"
  44. >
  45. <span @click="fourVendors(city.code)"> {{city.name}}:</span>
  46. <span :title="city.rname">{{city.rname | filterImgNames}}</span>
  47. </el-checkbox>
  48. </el-checkbox-group>
  49. </section>
  50. <!--维护有多个值的信息-->
  51. <section>
  52. <p class="text-message">维护有多个值的信息点</p>
  53. <span class="small">选择值的更新方式</span>
  54. <el-radio-group
  55. v-model="radio"
  56. @change="maintenance"
  57. >
  58. <el-radio :label="1">以增量方式维护</el-radio>
  59. <el-radio :label="2">以覆盖方式维护</el-radio>
  60. </el-radio-group>
  61. <div style="margin: 15px "></div>
  62. <div class="checkbox">
  63. <p v-for="(item,index) in newEnclosure">
  64. <el-checkbox
  65. v-model="form[item.Path]"
  66. >
  67. <span @click="multiple(item.Path)">{{item.InfoPointName}}</span>
  68. </el-checkbox>
  69. <span
  70. class="text-color"
  71. v-for="i in item.value"
  72. >{{i.Name | filterImgName}}</span>
  73. </p>
  74. </div>
  75. </section>
  76. <el-button
  77. class="next-step"
  78. @click="next"
  79. >下一步
  80. </el-button>
  81. </div>
  82. <div
  83. v-show="active === 1"
  84. class="all-message"
  85. >
  86. <el-table
  87. ref="multipleTable"
  88. :data="tableData"
  89. max-height="300"
  90. tooltip-effect="dark"
  91. style="width:100%;margin-bottom: 10px"
  92. @selection-change="handleSelectionChange"
  93. >
  94. <el-table-column
  95. type="selection"
  96. width="55"
  97. />
  98. <el-table-column
  99. label="设备本地名称"
  100. width=""
  101. >
  102. <template slot-scope="scope">{{scope.row.EquipLocalName}}</template>
  103. </el-table-column>
  104. <el-table-column
  105. prop="EquipLocalID"
  106. label="设备本地编码"
  107. width="120"
  108. />
  109. <el-table-column
  110. prop="build"
  111. label="所属建筑楼层"
  112. show-overflow-tooltip
  113. />
  114. </el-table>
  115. <my-pagination
  116. @change="getAllData"
  117. :page="page"
  118. ></my-pagination>
  119. <el-button
  120. type="primary"
  121. @click="maintenanceSelect"
  122. style="margin-top:10px"
  123. >维护已选
  124. </el-button>
  125. <el-button
  126. @click="active = 0"
  127. style="margin-right: 10px;margin-top:10px"
  128. >上 一 步
  129. </el-button>
  130. </div>
  131. </el-dialog>
  132. </template>
  133. <script>
  134. import myPagination from "@/components/ledger/lib/myPagination"
  135. import tools from "@/utils/buildfloor/tools";
  136. export default {
  137. name: "batchDialog",
  138. props: ['firmName', 'allObject', 'page', 'information','newEnclosure'],
  139. components: {myPagination},
  140. data() {
  141. return {
  142. form:{},
  143. batchDialog: false,//dialog
  144. active: 0,//进度条
  145. checkAll: false,//全选
  146. isIndeterminate: true,
  147. checkedCities: [],//选择的项,单项
  148. firm: [
  149. {
  150. name: "生产厂家/品牌型号",
  151. code: "DPManufacturerID",
  152. num: 2,
  153. }, {
  154. name: "供应商信息",
  155. code: "DPSupplierID",
  156. num: 8
  157. }, {
  158. name: "维修商信息",
  159. code: "DPMaintainerID",
  160. num: 35
  161. }, {
  162. name: "保险公司信息",
  163. code: "DPInsurerID",
  164. num: 42
  165. }
  166. ],
  167. radio: 1, //1增加,2覆盖
  168. checkedFile: [],//多项
  169. multipleSelection: [],//checkbox选择的对象数组
  170. filterList: [],//过滤单项选择的值
  171. deviceList: [],//过滤全选数据
  172. onlySelect: [],//检测是否有勾选单值信息
  173. videoModel: {
  174. archive: false,
  175. checkReport: false,
  176. drawing: false,
  177. installDrawing: false,
  178. insuranceFile: false,
  179. installPic: false,
  180. nameplate: false,
  181. pic: false
  182. },
  183. }
  184. },
  185. watch: {
  186. information() {
  187. return this.information
  188. },
  189. newEnclosure:{
  190. immediate:true,
  191. handler(val){
  192. this.newEnclosure = val
  193. }
  194. }
  195. },
  196. created() {
  197. this.$forceUpdate()
  198. },
  199. computed: {
  200. newFirm() {
  201. this.firm.map(item => {
  202. if (item.num === this.firmName.num) {
  203. item.rname = this.firmName.name
  204. item.info = this.firmName
  205. }
  206. return item
  207. })
  208. return this.firm
  209. },
  210. tableData() {
  211. this.allObject.map(item => {
  212. let build = ''
  213. if (item.Building && item.Floor) {
  214. build = item.Building.BuildLocalName + ' - ' + item.Floor.FloorLocalName
  215. } else if (item.Building) {
  216. build = item.Building.BuildLocalName
  217. } else if (item.Floor) {
  218. build = item.Floor.FloorLocalName
  219. } else {
  220. build = '-'
  221. }
  222. item.build = build
  223. return item
  224. })
  225. return this.allObject
  226. },
  227. },
  228. filters: {
  229. filterImgName(value) {
  230. if (value && value.length > 16) {
  231. return value.substring(0, 12) + '...'
  232. } else {
  233. return value
  234. }
  235. } ,
  236. filterImgNames(value) {
  237. if (value && value.length > 16) {
  238. return value.substring(0, 16) + '...'
  239. } else {
  240. return value
  241. }
  242. }
  243. },
  244. methods: {
  245. next() { //下一步按钮
  246. // if (this.active++ > 1) this.active = 0
  247. this.deviceList = this.firm.filter(item => item.info)
  248. // if (!this.onlySelect.length) { //对单项全选进行过滤
  249. // this.$message({
  250. // message: '还没有选择单值信息哦',
  251. // type: 'warning'
  252. // });
  253. // return false
  254. // }
  255. let fillIn = this.onlySelect.some(i => !i.info)
  256. if (fillIn) {
  257. this.$message({
  258. message: '请填写勾选信息',
  259. type: 'warning'
  260. });
  261. return false
  262. }
  263. // if (!this.deviceList.length) { //对单项全选进行过滤
  264. // this.$message({
  265. // message: '单值信息没有填写哦',
  266. // type: 'warning'
  267. // });
  268. // return false
  269. // }
  270. if (this.checkAll) { // 如果单项全选
  271. if (this.deviceList.length < 4) { //对单项全选进行过滤
  272. this.$message({
  273. message: '单值的信息点存在未填写',
  274. type: 'warning'
  275. });
  276. return false
  277. } else {
  278. this.active++
  279. }
  280. } else {
  281. this.active++
  282. }
  283. },
  284. handleCheckChange(val) { //全选
  285. this.checkedCities = val ? this.firm : []
  286. this.isIndeterminate = false
  287. },
  288. handleCheckedCitiesChange(value) { //维护单项触发
  289. this.onlySelect = value
  290. this.filterList = value.filter(item => item.info)
  291. let checkCount = value.length
  292. this.checkAll = checkCount === this.firm.length
  293. this.isIndeterminate = checkCount > 0 && checkCount < this.firm.length
  294. },
  295. handleCheckedFileChange(value) { //维护多项触发
  296. },
  297. fourVendors(code) {
  298. this.$emit('code', code)
  299. },
  300. // 选择维护方式
  301. maintenance(val) {
  302. },
  303. maintenanceSelect() { //维护已选
  304. if (!this.multipleSelection.length) {
  305. this.$message({
  306. message: '还没有选择实例哦',
  307. type: 'warning'
  308. });
  309. return false
  310. }
  311. let arr = []
  312. // DPSupplierID 供应商 DPManufacturerID 生产商 DPBrandID 品牌
  313. // DPSpecificationID 型号 DPInsurerID 保险商 DPMaintainerID 维修商
  314. this.multipleSelection.forEach(item => {
  315. let EquipID = item.EquipID
  316. arr.push({EquipID})
  317. })
  318. let Id = {}
  319. let single = {};
  320. // this.filterList 单选数组,取到需要数据
  321. // 过滤数组,取对象
  322. this.checkedCities.filter(item => item.num === 2).forEach(i => { //型号
  323. if (i.info) {
  324. let {venderName, brandName, Specification, venderId, brandId, specificationId} = i.info
  325. single.EquipManufactor = {
  326. Manufacturer: venderName,
  327. Brand: brandName,
  328. Specification: Specification
  329. }
  330. Id.DPManufacturerID = venderId
  331. Id.DPBrandID = brandId
  332. Id.DPSpecificationID = specificationId
  333. }
  334. })
  335. this.checkedCities.filter(item => item.num === 8).forEach(i => { //供应商8
  336. if (i.info) {
  337. let {website, name, venderId} = i.info
  338. single.SupplyPurchase = {
  339. SupplierWeb: website,
  340. Supplier: name,
  341. }
  342. Id.DPSupplierID = venderId
  343. }
  344. })
  345. this.checkedCities.filter(item => item.num === 35).forEach(i => { //维修商
  346. if (i.info) {
  347. let {name, venderId} = i.info
  348. single.OperationMainte = {
  349. Maintainer: name
  350. }
  351. Id.DPMaintainerID = venderId
  352. }
  353. })
  354. let insurance = this.checkedCities.filter(item => item.num === 42)
  355. if (insurance.length) {
  356. insurance.forEach(i => { //保险
  357. if (i.info) {
  358. let {website, name, venderId} = i.info
  359. single.InsuranceDoc = {
  360. Insurer: name,
  361. InsurerWeb: website,
  362. InsuranceFile: this.information.insuranceFile.InsuranceFile.length && this.radio === 2 ? this.information.insuranceFile.InsuranceFile : undefined
  363. }
  364. Id.DPInsurerID = venderId
  365. }
  366. })
  367. } else {
  368. if (this.radio === 2 && this.information.insuranceFile.InsuranceFile.length) {
  369. single.InsuranceDoc = {
  370. InsuranceFile: this.information.insuranceFile.InsuranceFile.length ? this.information.insuranceFile.InsuranceFile : undefined
  371. }
  372. }
  373. }
  374. // this.information 多选信息
  375. let valuable = [], newValuable = []
  376. valuable = this.newEnclosure.filter(i=>this.form[i.Path] && i.value ).forEach(({ InfoPointCode, value }) => newValuable[InfoPointCode] = value);
  377. // console.log( newValuable,'多选信息')
  378. if (this.radio === 1) { //组装数据,根据是覆盖该是增量,1是增量
  379. // 1:单选数据
  380. let arr1 = this.deepCopy(arr).map(item => ({
  381. ...Id,
  382. ...item,
  383. LedgerParam: {...single}
  384. }))
  385. let arr2 = this.deepCopy(arr).map(item => ({
  386. ...item,
  387. ...newValuable
  388. }))
  389. this.$emit('upDataDevice', 1, arr1, arr2)
  390. }
  391. if (this.radio === 2) {
  392. let param = {}
  393. this.newEnclosure.forEach(({Path,value})=>param[Path] = value)
  394. param = tools.formatData(param)
  395. let arr3 = this.deepCopy(arr).map(item => ({
  396. ...Id,
  397. ...item,
  398. ...param
  399. }))
  400. this.$emit('upDataDevice', 2, arr3)
  401. }
  402. this.closeDialog()
  403. },
  404. closeDialog() { //关闭弹窗,返回初始状态
  405. this.batchDialog = false
  406. this.clearData()
  407. },
  408. clearData() { //清空规则 filterList
  409. this.active = 0
  410. this.checkedCities = []//清空单项的checkbox
  411. this.firm.forEach(item => {
  412. item.rname = ''
  413. item.info = ''
  414. })
  415. // this.filterList = []
  416. this.onlySelect = []
  417. // this.deviceList = []
  418. this.radio = 1 //返回到默认增量
  419. //清空附件信息
  420. for(let i in this.form) {
  421. this.form[i] = false
  422. }
  423. this.newEnclosure.map(i=>{
  424. this.$set(i,'value',[])
  425. })
  426. },
  427. handleSelectionChange(val) {
  428. this.multipleSelection = val
  429. },
  430. getAllData() {
  431. this.$emit('getAllData')
  432. },
  433. multiple(val) {
  434. this.$emit('multiples',val)
  435. },
  436. deepCopy(obj) {
  437. return JSON.parse(JSON.stringify(obj))
  438. }
  439. }
  440. }
  441. </script>
  442. <style scoped lang="less">
  443. .batchContainer {
  444. /deep/ .el-step__description {
  445. margin: 2% 0;
  446. }
  447. .text-color {
  448. color: #409EFF
  449. }
  450. .el-checkbox-group {
  451. display: flex;
  452. justify-content: space-between;
  453. flex-direction: row;
  454. flex-wrap: wrap;
  455. .el-checkbox {
  456. width: 43%;
  457. }
  458. .el-checkbox:last-of-type {
  459. margin-right: 30px;
  460. }
  461. }
  462. .next-step {
  463. display: block;
  464. float: right;
  465. }
  466. .checkbox {
  467. display: flex;
  468. justify-content: space-between;
  469. flex-direction: row;
  470. flex-wrap: wrap;
  471. p {
  472. width: 50%;
  473. }
  474. .el-checkbox:last-of-type {
  475. margin-right: 10px;
  476. }
  477. }
  478. .text-message {
  479. overflow: hidden;
  480. margin-top: 10px;
  481. color: #333;
  482. border-left: 8px solid #333;
  483. text-indent: 10px;
  484. font-weight: 600;
  485. }
  486. .small {
  487. font-size: 12px;
  488. color: #555;
  489. }
  490. .all-message {
  491. overflow: hidden;
  492. button {
  493. float: right;
  494. padding: 10px;
  495. margin-left: 5px;
  496. }
  497. }
  498. }
  499. </style>