index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. <template>
  2. <div>
  3. <el-breadcrumb class="heading">
  4. <el-breadcrumb-item :to="{ path: '/' }">平台首页</el-breadcrumb-item>
  5. <el-breadcrumb-item :to="{ path: '/oilsupplier/basisbuild' }">基建类资质对照表</el-breadcrumb-item>
  6. </el-breadcrumb>
  7. <el-card class="box-card" style="height: calc(100vh - 115px);">
  8. <div slot="header">
  9. <span>
  10. <i class="icon icon-table2"></i> 基建类资质对照表
  11. </span>
  12. <span style="float: right;">
  13. <router-link :to="'/oilsupplier/basisbuild/add/operation'">
  14. <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;">添加</el-button>
  15. </router-link>
  16. <el-button type="primary" size="mini" style="margin-left:10px; margin-top: -4px;" @click="exportExcel">导出
  17. </el-button>
  18. </span>
  19. <el-form ref="form" :inline="true" style="float: right; margin-top: -10px">
  20. <el-form-item label="上报时间">
  21. <el-date-picker size="mini" style="width: 220px" v-model="CreateOn" type="daterange" range-separator="至"
  22. start-placeholder="生成日期" end-placeholder="结束日期"></el-date-picker>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-dropdown split-button type="primary" size="mini" @click="handleSearch" @command="searchCommand">
  26. 查询
  27. <el-dropdown-menu slot="dropdown">
  28. <el-dropdown-item command="search">高级查询</el-dropdown-item>
  29. <el-dropdown-item command="clear">查询重置</el-dropdown-item>
  30. </el-dropdown-menu>
  31. </el-dropdown>
  32. </el-form-item>
  33. </el-form>
  34. </div>
  35. <el-table :data="entityList" id="rebateSetTable" size="mini" border height="calc(100vh - 243px)" style="width: 100%"
  36. @sort-change="orderby">
  37. <el-table-column label="操作" min-width="200" align="center" fixed="right">
  38. <template slot-scope="scope">
  39. <router-link :to="'/oilsupplier/basisbuild/' + scope.row.Id + '/operation'">
  40. <el-button type="primary" plain title="编辑" size="mini">编辑</el-button>
  41. </router-link>
  42. <el-dropdown @command="MoreCmdClick">
  43. <el-button size="mini" type="primary" plain>
  44. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  45. </el-button>
  46. <el-dropdown-menu slot="dropdown">
  47. <el-dropdown-item :command="GetCommand('Set', scope.row)">审核部门</el-dropdown-item>
  48. <!--<el-dropdown-item :command="GetCommand('Delete', scope.row)">删除数据</el-dropdown-item>-->
  49. </el-dropdown-menu>
  50. </el-dropdown>
  51. <!--<el-popover placement="top" title="提示">-->
  52. <!--<el-alert-->
  53. <!--title=""-->
  54. <!--description="确认要删除吗?"-->
  55. <!--type="warning"-->
  56. <!--:closable="false">-->
  57. <!--</el-alert>-->
  58. <!--<br/>-->
  59. <!--<div style="text-align: right; margin: 0">-->
  60. <!--<el-button type="primary" size="mini" @click="deleteEntity(scope.row)">删除</el-button>-->
  61. <!--</div>-->
  62. <!--<el-button slot="reference" type="primary" plain title="删除" style="margin-left:3px" size="mini">删除</el-button>-->
  63. <!--</el-popover>-->
  64. </template>
  65. </el-table-column>
  66. <el-table-column v-for="column in tableColumns" :prop="column.prop" sortable :min-width="column.width"
  67. :label="column.label" :key="column.Id" align="center" show-overflow-tooltip>
  68. <template slot-scope="scope">
  69. {{ transferStr(scope.row[column.prop]) }}
  70. </template>
  71. </el-table-column>
  72. <!--动态显示的表头-->
  73. <el-table-column v-for="column in dynamicTableColumns" :prop="column.prop" sortable :width="300"
  74. :key="column.Id" :label="column.label" align="center" show-overflow-tooltip>
  75. <template slot-scope="scope">
  76. {{ transferStr(scope.row[column.prop]) }}
  77. </template>
  78. </el-table-column>
  79. <!--<el-table-column prop="CreateOn" sortable min-width="150" label="生成时间" align="center" show-overflow-tooltip>
  80. <template slot-scope="scope">
  81. {{ jstimehandle(scope.row.CreateOn+'') }}
  82. </template>
  83. </el-table-column>-->
  84. </el-table>
  85. <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
  86. :page-sizes="[10, 15, 20, 25]" :page-size="size" layout="total, sizes, prev, pager, next, jumper"
  87. :total="currentItemCount">
  88. </el-pagination>
  89. </el-card>
  90. <el-dialog title="高级查询" :visible.sync="dialogVisible" width="720px">
  91. <el-form ref="advancedsearchForm" label-width="110px">
  92. <el-row>
  93. <el-col :span="12">
  94. <el-form-item label="生成时间">
  95. <el-date-picker size="mini" v-model="CreateOn" type="daterange" style="width:100%" range-separator="至"
  96. start-placeholder="生成日期" end-placeholder="结束日期"></el-date-picker>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="12">
  100. <el-form-item label="编码">
  101. <el-input size="mini" v-model="searchForm.Code" style="width:100%" placeholder="请输入"></el-input>
  102. </el-form-item>
  103. </el-col>
  104. <el-col :span="12">
  105. <el-form-item label="名称">
  106. <el-input size="mini" v-model="searchForm.Name" style="width:100%" placeholder="请输入"></el-input>
  107. </el-form-item>
  108. </el-col>
  109. </el-row>
  110. </el-form>
  111. <span slot="footer" class="dialog-footer">
  112. <el-button size="mini" @click="dialogVisible = false">取 消</el-button>
  113. <el-button size="mini" type="primary" @click="handleSearch">查 询</el-button>
  114. </span>
  115. </el-dialog>
  116. <el-dialog title="设置审批部门" :visible.sync="deptsetVisible">
  117. <el-row>
  118. <el-col :span="12">
  119. 审批步骤:
  120. <el-select v-model="setForm.AuditStepCode" ref="selectAuditStep" placeholder="请选择" size="small">
  121. <el-option v-for="item in AuditStepOptions" :key="item.Id" :label="item.Key" :value="item.Value">
  122. </el-option>
  123. </el-select>
  124. </el-col>
  125. <el-col :span="12">
  126. 审批部门:
  127. <el-tree style="border: 0" show-checkbox node-key="id" :data="operationOrganizeData" :props="organizeProps"
  128. ref="operationOriganizeTree">
  129. </el-tree>
  130. </el-col>
  131. </el-row>
  132. <div slot="footer">
  133. <el-button @click="deptsetVisible = false">取消</el-button>
  134. <el-button type="primary" @click="saveApprovalDept()">确定</el-button>
  135. </div>
  136. </el-dialog>
  137. </div>
  138. </template>
  139. <script>
  140. import {
  141. mapGetters
  142. } from 'vuex'
  143. import api from '@/api/oilsupplier/basisbuild'
  144. import setapi from '@/api/oilsupplier/oilclassorgset'
  145. import FileSaver from "file-saver";
  146. import XLSX from "xlsx";
  147. export default {
  148. computed: {
  149. ...mapGetters({
  150. authUser: 'authUser'
  151. })
  152. },
  153. name: 'oilbasisbuild',
  154. data() {
  155. return {
  156. deptsetVisible: false,
  157. dialogVisible: false,
  158. // 列表数据
  159. entityList: [],
  160. // 分页参数
  161. size: 10,
  162. currentPage: 1,
  163. currentItemCount: 0,
  164. // 列表排序
  165. Column: {
  166. Order: '',
  167. Prop: ''
  168. },
  169. // 查询时间
  170. CreateOn: [],
  171. // 查询项
  172. searchFormReset: {},
  173. searchForm: {
  174. Id: '',
  175. Code: '',
  176. Name: '',
  177. F01: '',
  178. F02: '',
  179. F03: '',
  180. F04: '',
  181. F05: '',
  182. F06: '',
  183. F07: '',
  184. F08: '',
  185. F09: '',
  186. F10: '',
  187. F11: '',
  188. F12: '',
  189. F13: '',
  190. F14: '',
  191. F15: '',
  192. F16: '',
  193. F17: '',
  194. F18: '',
  195. F19: '',
  196. F20: '',
  197. F21: '',
  198. F22: '',
  199. F23: '',
  200. F24: '',
  201. F25: '',
  202. F26: '',
  203. F27: '',
  204. F28: '',
  205. F29: '',
  206. F30: '',
  207. F31: '',
  208. F32: '',
  209. F33: '',
  210. F34: '',
  211. F35: '',
  212. F36: '',
  213. F37: '',
  214. F38: '',
  215. F39: '',
  216. F40: '',
  217. Remark: ''
  218. },
  219. setForm: {
  220. SupplierTypeCode: '02',
  221. SupplierTypeName: '基建类',
  222. AuditStepCode: '',
  223. AuditStepName: ''
  224. },
  225. dynamicTableColumns: [],
  226. tableColumns: [
  227. {
  228. prop: 'Code',
  229. label: '编码',
  230. width: 100,
  231. sort: true
  232. },
  233. {
  234. prop: 'Name',
  235. label: '名称',
  236. width: 260,
  237. sort: true
  238. }
  239. ],
  240. organizeProps: {
  241. value: 'id',
  242. label: 'name',
  243. children: 'children'
  244. },
  245. operationOrganizeData: [],
  246. AuditStepOptions: []
  247. }
  248. },
  249. created() {
  250. // 查询条件初始值备份
  251. Object.assign(this.searchFormReset, this.searchForm)
  252. this.initTableHeader()
  253. // 查询列表
  254. this.initDatas()
  255. this.getDictOptions()
  256. },
  257. methods: {
  258. initTableHeader() {
  259. setapi.initBbTableHeader(this.$axios).then(res => {
  260. console.log(res)
  261. this.dynamicTableColumns = res.data.items
  262. })
  263. },
  264. saveApprovalDept() {
  265. let organizeids = []
  266. let organize = this.$refs.operationOriganizeTree.getCheckedNodes()
  267. organize.forEach(row => {
  268. organizeids.push(row.id)
  269. })
  270. this.setForm.AuditStepName = this.$refs.selectAuditStep.selectedLabel + ''
  271. setapi.addOrganize(this.selecteclassid, organizeids, this.setForm, this.$axios).then(res => {
  272. if (res.data.code === 0) {
  273. this.$message({
  274. type: 'success',
  275. message: res.data.message
  276. })
  277. this.deptsetVisible = false
  278. } else {
  279. this.$message({
  280. type: 'warning',
  281. message: res.data.message
  282. })
  283. }
  284. console.log(res.data)
  285. }).catch(err => {
  286. console.log(err)
  287. })
  288. },
  289. deptSet(val) {
  290. let stcode = this.setForm.SupplierTypeCode
  291. this.deptsetVisible = true
  292. this.selecteclassid = val.Id
  293. // request
  294. this.$axios.get('classorgsetting/getdepartment?id=' + this.selecteclassid + '&stcode=' + stcode, {})
  295. .then(res => {
  296. // response
  297. this.setForm.AuditStepCode = res.data.AuditStepCode
  298. this.operationOrganizeData = window.toolfun_gettreejson(res.data.Organize, 'id', 'pId', 'id,name,scope')
  299. if (!res.data.SelectedOrganize) {
  300. res.data.SelectedOrganize = []
  301. }
  302. this.$refs.operationOriganizeTree.setCheckedKeys(res.data.SelectedOrganize, true)
  303. })
  304. .catch(err => {
  305. console.log(err)
  306. })
  307. },
  308. MoreCmdClick(cmd) {
  309. if (cmd.Command === 'Set') {
  310. this.deptSet(cmd.row)
  311. } else if (cmd.Command === 'Delete') {
  312. this.deleteEntity(cmd.row)
  313. }
  314. },
  315. GetCommand(cmdType, row) {
  316. let cmd = {}
  317. cmd.Command = cmdType
  318. cmd.row = row
  319. return cmd
  320. },
  321. initDatas() {
  322. // 分页及列表条件
  323. let params = {
  324. _currentPage: this.currentPage,
  325. _size: this.size,
  326. Order: this.Column.Order,
  327. Prop: this.Column.Prop
  328. }
  329. let myCreateOn = []
  330. // 解析时间
  331. if (this.CreateOn != null && this.CreateOn.length === 2) {
  332. this.CreateOn[1].setHours(23)
  333. this.CreateOn[1].setMinutes(59)
  334. this.CreateOn[1].setSeconds(59)
  335. myCreateOn.push(this.formatDateTime(this.CreateOn[0]))
  336. myCreateOn.push(this.formatDateTime(this.CreateOn[1]))
  337. }
  338. // 查询条件
  339. Object.assign(params, this.searchForm)
  340. // 访问接口
  341. api.getList(myCreateOn.join(','), params, this.$axios).then(res => {
  342. this.entityList = res.data.items
  343. this.currentItemCount = res.data.currentItemCount
  344. }).catch(err => {
  345. console.error(err)
  346. })
  347. },
  348. getDictOptions() {
  349. api.getDictList(this.$axios).then(res => {
  350. // this.dictOptions.customerList = res.data.items['customerList']
  351. // this.dictOptions.projectList = res.data.items['projectList']
  352. this.AuditStepOptions = res.data.items['AuditStep']
  353. }).catch(err => {
  354. console.error(err)
  355. })
  356. },
  357. exportExcel() {
  358. /* generate workbook object from table */
  359. let wb = XLSX.utils.table_to_book(
  360. document.querySelector("#rebateSetTable")
  361. );
  362. /* get binary string as output */
  363. let wbout = XLSX.write(wb, {
  364. bookType: "xlsx",
  365. bookSST: true,
  366. type: "array"
  367. });
  368. try {
  369. FileSaver.saveAs(
  370. new Blob([wbout], {
  371. type: "application/octet-stream"
  372. }),
  373. "BasisBuild.xlsx"
  374. );
  375. } catch (e) {
  376. if (typeof console !== "undefined") console.log(e, wbout);
  377. }
  378. return wbout;
  379. },
  380. searchCommand(command) {
  381. if (command === 'search') {
  382. this.dialogVisible = true
  383. } else if (command === 'clear') {
  384. this.clearSearch()
  385. }
  386. },
  387. // 列表排序功能
  388. orderby(column) {
  389. if (column.order === 'ascending') {
  390. this.Column.Order = 'asc'
  391. } else if (column.order === 'descending') {
  392. this.Column.Order = 'desc'
  393. }
  394. this.Column.Prop = column.prop
  395. this.initDatas()
  396. },
  397. clearSearch() {
  398. Object.assign(this.searchForm, this.searchFormReset)
  399. // this.searchForm = this.searchFormReset;
  400. this.CreateOn = ''
  401. this.initDatas()
  402. },
  403. handleSearch() {
  404. this.currentPage = 1
  405. this.dialogVisible = false
  406. this.initDatas()
  407. },
  408. handleCurrentChange(value) {
  409. this.currentPage = value
  410. this.initDatas()
  411. },
  412. handleSizeChange(value) {
  413. this.size = value
  414. this.currentPage = 1
  415. this.initDatas()
  416. },
  417. deleteEntity(row) {
  418. this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
  419. confirmButtonText: '确定',
  420. cancelButtonText: '取消',
  421. type: 'warning'
  422. }).then(() => {
  423. api.deleteEntity(row.Id, this.$axios).then(res => {
  424. if (res.data.code === 0) {
  425. this.initDatas()
  426. this.$message({
  427. type: 'success',
  428. message: res.data.message
  429. })
  430. } else {
  431. this.$message({
  432. type: 'warning',
  433. message: res.data.message
  434. })
  435. }
  436. }).catch(err => {
  437. console.error(err)
  438. })
  439. }).catch(err => {
  440. console.error(err)
  441. })
  442. },
  443. transferStr(val) {
  444. if (val === '1') {
  445. return '是'
  446. }
  447. if (val === '0') {
  448. return ''
  449. } else {
  450. return val
  451. }
  452. },
  453. jstimehandle(val) {
  454. if (val === '') {
  455. return '----'
  456. } else if (val === '0001-01-01T08:00:00+08:00') {
  457. return '----'
  458. } else if (val === '5000-01-01T23:59:59+08:00') {
  459. return '永久'
  460. } else {
  461. val = val.replace('T', ' ')
  462. return val.substring(0, 10)
  463. }
  464. },
  465. formatDateTime(date) {
  466. var y = date.getFullYear()
  467. var m = date.getMonth() + 1
  468. m = m < 10 ? ('0' + m) : m
  469. var d = date.getDate()
  470. d = d < 10 ? ('0' + d) : d
  471. var h = date.getHours()
  472. var minute = date.getMinutes()
  473. minute = minute < 10 ? ('0' + minute) : minute
  474. return y + '-' + m + '-' + d + ' ' + h + ':' + minute
  475. }
  476. }
  477. }
  478. </script>