config.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div class="content-container goaf">
  3. <el-row class="tool-bar">
  4. <el-col :span="3" class="left">
  5. <div class="content-title">
  6. 采空区
  7. </div>
  8. </el-col>
  9. <el-col :span="21" class="right">
  10. <el-select v-model="conditions.goafOrebelt" class="search-input m-right-15" filterable placeholder="矿带" clearable @change="changeArea(1)">
  11. <el-option v-for="(item,index) in goafOrebelts" :key="index" :value="item" :label="item" />
  12. </el-select>
  13. <el-select v-model="conditions.goafOrebody" class="search-input m-right-15" filterable placeholder="矿体" clearable @change="changeArea(2)">
  14. <el-option v-for="(item,index) in goafOrebodys" :key="index" :value="item.goafOrebody" :label="item.goafOrebody" />
  15. </el-select>
  16. <el-select v-model="conditions.goafOreheight" class="search-input m-right-15" filterable placeholder="中段" clearable @change="changeArea(3)">
  17. <el-option v-for="(item,index) in goafOreheights" :key="index" :value="item.goafOreheight" :label="item.goafOreheight" />
  18. </el-select>
  19. <el-select v-model="conditions.goafId" class="search-input m-right-15" filterable placeholder="采空区编号" clearable @change="changeArea(4)">
  20. <el-option v-for="item in goafNames" :key="item.goafId" :value="item.goafId" :label="item.goafName" />
  21. </el-select>
  22. <el-button type="primary" style="margin-right: 10px;" @click="getData">查询</el-button>
  23. <!-- <el-button type="primary" @click="batchDown">批量下载二维码</el-button> -->
  24. </el-col>
  25. </el-row>
  26. <el-row class="m-top-15">
  27. <el-table v-loading="listLoading" class="page-table" border fit :data="dataList">
  28. <el-table-column type="index" label="序号" header-align="center" align="center" width="60" />
  29. <el-table-column prop="goafOrebelt" label="矿带">
  30. <template v-slot="{row}">
  31. <span>{{ convertNum(row.goafOrebelt) }}</span>
  32. </template>
  33. </el-table-column>
  34. <el-table-column prop="goafOrebody" label="矿体" />
  35. <el-table-column prop="goafOreheight" label="中段" />
  36. <el-table-column prop="goafName" label="采空区名称" />
  37. <el-table-column prop="positionName" label="检查表" header-align="center" align="center">
  38. <template v-slot="{row}">
  39. <!-- <span v-if="!isNull(row.goafChecklistId)" class="icon iconfont icon-erweima" style="color:#fff" @click="showQrcode(row)" /> -->
  40. <span v-if="row.goafChecklistIsbind===1">{{ row.goafChecklistTitle }}</span>
  41. <span v-else>未绑定</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column prop="goafInfoRemak" label="备注" align="right">
  45. <template v-slot="{row}">
  46. <span>{{ row.goafInfoRemak||'--' }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="操作" header-align="center" align="center" width="180">
  50. <template v-slot="{row}">
  51. <el-button size="mini" type="text" style="color:#1B81FF" @click="showDetail(row)">详情</el-button>
  52. <el-button v-if="row.goafChecklistIsbind===0" size="mini" type="text" style="color:#1B81FF" @click="handleUpdate(row)">绑定</el-button>
  53. <el-button v-else size="mini" type="text" style="color:#E44E2D" @click="handleDelete(row)">解绑</el-button>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <div class="pagination-container" style="float:right;margin-right:40px;">
  58. <pagination v-show="total>0" :total="total" :page.sync="conditions.page" :limit.sync="conditions.limit" @pagination="getData" />
  59. </div>
  60. </el-row>
  61. <check-list-bind ref="bind" @formSuccess="getData" />
  62. <detail ref="detail" />
  63. <QrCode ref="qrcode" />
  64. <div id="qrcode" ref="qrcodeModal" style="position:fixed;top:-9999px;" />
  65. </div>
  66. </template>
  67. <script>
  68. import html2canvas from 'html2canvas'
  69. import JSZip from 'jszip'
  70. import saveAs from 'file-saver'
  71. import QRCode from 'qrcodejs2'
  72. import { getGoafBaseInfoByPage, updateGoaf, getGoafBaseInfo } from '@/api/goaf/info'
  73. import { Pagination } from '@/components'
  74. import { NumConvertLM } from '@/utils'
  75. import { QrCode } from '@/components'
  76. // import checkListBind from '@/views/goaf/info/components/Goaf'
  77. import checkListBind from './components/checkListBind.vue'
  78. import Detail from '@/views/goaf/info/components/detail'
  79. var zip = new JSZip()
  80. export default {
  81. components: { Pagination, QrCode, checkListBind, Detail },
  82. data() {
  83. return {
  84. dataList: [],
  85. total: 0,
  86. listLoading: false,
  87. goafList: [],
  88. goafOrebelts: [],
  89. goafOrebodys: [],
  90. goafOreheights: [],
  91. goafNames: [],
  92. conditions: {
  93. page: 1,
  94. limit: 10,
  95. goafId: '',
  96. goafOrebelt: '',
  97. goafOrebody: '',
  98. goafOreheight: ''
  99. }
  100. }
  101. },
  102. created() {
  103. this.getData()
  104. getGoafBaseInfo().then((res) => {
  105. const goafOrebelts = res.data.map(item => item.goafOrebelt)
  106. this.goafOrebelts = [...new Set(goafOrebelts)]
  107. this.goafList = res.data
  108. })
  109. },
  110. methods: {
  111. convertNum(num) {
  112. return num ? NumConvertLM(num) : '--'
  113. },
  114. getData() {
  115. this.listLoading = true
  116. if (this.conditions.goafOrebelt === '') delete this.conditions.goafOrebelt
  117. if (this.conditions.goafOrebody === '') delete this.conditions.goafOrebody
  118. if (this.conditions.goafOreheight === '') delete this.conditions.goafOreheight
  119. if (this.conditions.goafName === '') delete this.conditions.goafName
  120. getGoafBaseInfoByPage(this.conditions).then((resp) => {
  121. this.listLoading = false
  122. const { code, msg, data, total } = resp
  123. if (code === 0) {
  124. this.dataList = data
  125. this.total = total
  126. } else {
  127. this.$message.error(msg)
  128. }
  129. })
  130. },
  131. changeArea(type) {
  132. const goafs = this.deeepClone(this.goafList)
  133. let goafOrebodys = this.deeepClone(this.goafOrebodys)
  134. let goafOreheights = this.deeepClone(this.goafOreheights)
  135. let goafNames = this.deeepClone(this.goafNames)
  136. if (type === 1) {
  137. goafOrebodys = goafs.filter(item => item.goafOrebelt === this.conditions.goafOrebelt)
  138. this.goafOrebodys = goafOrebodys
  139. this.goafOreheights = []
  140. this.goafNames = []
  141. this.conditions.goafOrebody = ''
  142. this.conditions.goafOreheight = ''
  143. this.conditions.goafName = ''
  144. this.conditions.goafId = ''
  145. } else if (type === 2) {
  146. goafOreheights = goafs.filter(item => (item.goafOrebody === this.conditions.goafOrebody) && (item.goafOrebelt === this.conditions.goafOrebelt))
  147. this.goafOreheights = goafOreheights
  148. this.goafNames = []
  149. this.conditions.goafOreheight = ''
  150. this.conditions.goafName = ''
  151. this.conditions.goafId = ''
  152. } else if (type === 3) {
  153. goafNames = goafs.filter(item => (item.goafOreheight === this.conditions.goafOreheight) && (item.goafOrebody === this.conditions.goafOrebody) && (item.goafOrebelt === this.conditions.goafOrebelt))
  154. this.goafNames = goafNames
  155. this.conditions.goafName = ''
  156. this.conditions.goafId = ''
  157. } else {
  158. for (let i = 0; i < goafNames.length; i++) {
  159. if (this.conditions.goafId === goafNames[i].goafId) {
  160. this.conditions.goafName = goafNames[i].goafName
  161. }
  162. }
  163. }
  164. this.$forceUpdate()
  165. },
  166. isNull(val) {
  167. if (val !== undefined && val !== 'undefined' && val !== null && val !== '' && val !== ' ') {
  168. return false
  169. }
  170. return true
  171. },
  172. showQrcode(row) {
  173. this.$refs.qrcode.draw(row.goafChecklistId)
  174. },
  175. batchDown() { /* 点击按钮获取制作二维码素材*/
  176. const content = JSON.parse(JSON.stringify(this.dataList))
  177. this.downloadMaterial(content)
  178. },
  179. downloadMaterial(content) { // 下载物料
  180. this.batch(content, '检查表')
  181. },
  182. async batch(arr, fileName) {
  183. const self = this
  184. window.loading = this.$loading({
  185. lock: true,
  186. text: '制作二维码中!',
  187. spinner: 'el-icon-loading',
  188. background: 'rgba(0, 0, 0, 0.7)'
  189. })
  190. zip = new JSZip()
  191. for (let i = 0; i < arr.length; i++) {
  192. const item = arr[i]
  193. await self.drawQrcode(item.type, item.goafChecklistId).catch(() => {
  194. window.loading.close()
  195. this.$message.error('导出失败')
  196. })
  197. await self.packMaterial(`${item.goafOrebelt}-${item.goafOrebody}-${item.goafOreheight}-${new Date().getTime()}`).catch(() => {
  198. window.loading.close()
  199. this.$message.error('导出失败')
  200. })
  201. }
  202. zip.generateAsync({
  203. type: 'blob'
  204. }).then((blob) => {
  205. saveAs(blob, fileName + '二维码物料.zip')
  206. window.loading.close()
  207. })
  208. },
  209. drawQrcode(url, sleep) { // 绘制二维码
  210. this.$refs.qrcodeModal.innerHTML = ''
  211. return new Promise((resolve) => {
  212. new QRCode('qrcode', {
  213. width: 400,
  214. height: 400,
  215. text: url.toString()
  216. })
  217. setTimeout(function() {
  218. resolve()
  219. }, sleep || 300)
  220. })
  221. },
  222. packMaterial(name) { // 打包处理
  223. if (!name) name = 'xxx'
  224. return new Promise((resolve, reject) => {
  225. html2canvas(document.getElementById('qrcode'), {
  226. backgroundColor: null,
  227. useCORS: true,
  228. dpi: 500,
  229. scale: 5
  230. }).then((canvas) => {
  231. let dataURL = canvas.toDataURL('photo/png')
  232. dataURL = dataURL.replace(/^data:image\/(png|jpg);base64,/, '')
  233. zip.file(name + '.jpg', dataURL, { base64: true })
  234. resolve()
  235. }).catch((e) => {
  236. reject(e)
  237. })
  238. })
  239. },
  240. showDetail(data) {
  241. this.$refs['detail'].showDetailModel(JSON.parse(JSON.stringify(data)))
  242. },
  243. // "Edit Risk" Model
  244. handleUpdate(data) {
  245. this.$refs['bind'].showEditModel(JSON.parse(JSON.stringify(data)))
  246. },
  247. // Delete Action
  248. handleDelete(data) {
  249. const { goafName } = data
  250. const formData = JSON.parse(JSON.stringify(data))
  251. formData.goafChecklistId = ''
  252. formData.goafChecklistTitle = ''
  253. formData.goafChecklistIsbind = 0
  254. this.$confirm(`此操作将解绑该数据${goafName}, 是否继续?`, '提示', {
  255. confirmButtonText: '确定',
  256. cancelButtonText: '取消',
  257. type: 'warning'
  258. }).then(() => {
  259. updateGoaf(formData).then((resp) => {
  260. const { msg } = resp
  261. this.getData()
  262. this.$message.success(msg)
  263. })
  264. }).catch(() => {
  265. this.$message.info('已取消删除')
  266. })
  267. },
  268. deeepClone(params) {
  269. return JSON.parse(JSON.stringify(params))
  270. }
  271. }
  272. }
  273. </script>
  274. <style lang="scss" scoped>
  275. @import "icon/iconfont.css";
  276. .content-container {
  277. background: #193142FF;
  278. margin: 10px 10px 10px 0;
  279. padding: 15px;
  280. height: calc(100vh - 90px);
  281. box-sizing: border-box;
  282. .content-title {
  283. font-size: 18px;
  284. font-weight: bold;
  285. color: #FFFFFF;
  286. font-weight: bold;
  287. background: linear-gradient(0deg, #FFFFFF 0%, #98A8B7 100%);
  288. background-clip: text;
  289. -webkit-background-clip: text;
  290. -webkit-text-fill-color: transparent;
  291. }
  292. .tool-bar {
  293. .left {
  294. float: left;
  295. }
  296. .right {
  297. float: right;
  298. text-align: right;
  299. }
  300. .title {
  301. line-height: 36px;
  302. font-size: 26px;
  303. }
  304. .search-input {
  305. width: 200px !important;
  306. }
  307. }
  308. .el-dropdown {
  309. margin: 0 10px;
  310. }
  311. }
  312. </style>
  313. <style lang="scss">
  314. .goaf .el-table__body tr.hover-row>td {
  315. background-color: #306379;
  316. }
  317. .goaf{
  318. .page-table{
  319. height: calc(100vh - 260px);
  320. overflow-y: auto;
  321. }
  322. }
  323. </style>