unit.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <div>
  3. <div class="search-term">
  4. <el-form :inline="true" :model="searchInfo" class="demo-form-inline">
  5. <el-form-item label="部门名称">
  6. <el-input v-model="searchInfo.unitName" clearable placeholder="请输入部门名称" />
  7. </el-form-item>
  8. <el-form-item label="部门类型">
  9. <el-select v-model="searchInfo.remark" clearable placeholder="请选择">
  10. <el-option
  11. v-for="dict in dict.type.department_type"
  12. :key="dict.value"
  13. :label="dict.label"
  14. :value="dict.label"
  15. />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button size="mini" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button>
  20. <el-button size="mini" type="primary" icon="el-icon-plus" @click="openDialog">新增部门</el-button>
  21. <!-- <el-button size="mini" type="primary" icon="el-icon-plus" @click="updateUnit">重新开始下期</el-button>-->
  22. <el-popover v-model:visible="deleteVisible" placement="top" width="160">
  23. <p>确定要删除吗?</p>
  24. <div style="text-align: right; margin: 0">
  25. <el-button size="mini" type="text" @click="deleteVisible = false">取消</el-button>
  26. <el-button size="mini" type="primary" @click="onDelete">确定</el-button>
  27. </div>
  28. <!-- <template #reference>-->
  29. <!-- <el-button icon="el-icon-delete" size="mini" type="danger" style="margin-left: 10px;">批量删除</el-button>-->
  30. <!-- </template>-->
  31. </el-popover>
  32. </el-form-item>
  33. </el-form>
  34. </div>
  35. <el-table
  36. ref="multipleTable"
  37. border
  38. stripe
  39. style="width: 100%"
  40. tooltip-effect="dark"
  41. :data="tableData"
  42. @selection-change="handleSelectionChange"
  43. >
  44. <!-- <el-table-column type="selection" width="55" />-->
  45. <!-- <el-table-column label="日期" width="180">-->
  46. <!-- <template #default="scope">{{ formatDate(scope.row.CreatedAt) }}</template>-->
  47. <!-- </el-table-column>-->
  48. <el-table-column label="部门名称" prop="unitName" />
  49. <el-table-column label="部门类型" prop="remark" />
  50. <el-table-column label="满分">
  51. <template #default="scope">{{ scope.row.unitMaxIntegral/100 }}</template>
  52. </el-table-column>
  53. <el-table-column label="扣分">
  54. <template #default="scope">{{ scope.row.unitIntegral/100 }}</template>
  55. </el-table-column>
  56. <el-table-column label="得分">
  57. <template #default="scope">{{ (scope.row.unitMaxIntegral-scope.row.unitIntegral)/100 }}</template>
  58. </el-table-column>
  59. <el-table-column label="得分率">
  60. <template #default="scope">{{ ((scope.row.unitMaxIntegral-scope.row.unitIntegral)/scope.row.unitMaxIntegral).toFixed(4)*100?((scope.row.unitMaxIntegral-scope.row.unitIntegral)/scope.row.unitMaxIntegral).toFixed(4)*100:0 }} %</template>
  61. </el-table-column>
  62. <el-table-column label="按钮组">
  63. <template #default="scope">
  64. <el-button size="small" type="primary" icon="el-icon-edit" class="table-button" @click="updateUnit(scope.row)">变更</el-button>
  65. <el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteRow(scope.row)">删除</el-button>
  66. <el-button size="small" type="primary" icon="el-icon-edit" @click="selecrUser(scope.row)">负责人管理</el-button>
  67. <el-button size="small" type="primary" icon="el-icon-edit" @click="selectPlace(scope.row)">添加考察点位</el-button>
  68. </template>
  69. </el-table-column>
  70. </el-table>
  71. <el-pagination
  72. layout="total, sizes, prev, pager, next, jumper"
  73. :current-page="page"
  74. :page-size="pageSize"
  75. :page-sizes="[10, 30, 50, 100]"
  76. :style="{float:'right',padding:'20px'}"
  77. :total="total"
  78. @current-change="handleCurrentChange"
  79. @size-change="handleSizeChange"
  80. />
  81. <el-dialog v-model="noticeList" title="选择负责人" width="500px" append-to-body>
  82. <el-form v-model="bindUser" label-width="120px">
  83. <el-row>
  84. <el-col :span="24">
  85. <el-form-item label="部门负责人" :rules="{required: true, message: '请选择部门负责人'}">
  86. <el-select
  87. v-model="bindUser.userList"
  88. filterable
  89. clearable
  90. multiple
  91. size="small"
  92. style="width: 240px"
  93. >
  94. <el-option
  95. v-for="id in Object.keys(userIds)"
  96. :key="id"
  97. :label="userIds[id]"
  98. :value="id"
  99. />
  100. </el-select>
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. </el-form>
  105. <div slot="footer" class="dialog-footer">
  106. <el-button type="primary" @click="saveUser">确 定</el-button>
  107. <el-button @click="closeSend">取 消</el-button>
  108. </div>
  109. </el-dialog>
  110. <el-dialog v-model="dialogFormVisible" :before-close="closeDialog" title="弹窗操作">
  111. <el-form :model="formData" label-position="right" label-width="80px">
  112. <el-form-item label="部门名称:">
  113. <el-input v-model="formData.unitName" clearable placeholder="请输入" />
  114. </el-form-item>
  115. <el-form-item label="部门类型:">
  116. <el-select v-model="formData.remark" clearable placeholder="请选择">
  117. <el-option
  118. v-for="dict in dict.type.department_type"
  119. :key="dict.label"
  120. :label="dict.label"
  121. :value="dict.label"
  122. />
  123. </el-select>
  124. </el-form-item>
  125. </el-form>
  126. <template #footer>
  127. <div class="dialog-footer">
  128. <el-button @click="closeDialog">取 消</el-button>
  129. <el-button type="primary" @click="enterDialog">确 定</el-button>
  130. </div>
  131. </template>
  132. </el-dialog>
  133. <el-dialog v-model="placesVisible" :before-close="closePlace" title="管理部门点位">
  134. <el-form :model="placesForm" label-position="right" label-width="80px">
  135. <el-form-item label="评分站点:">
  136. <el-select
  137. v-model="placesForm.placesId"
  138. filterable
  139. clearable
  140. multiple
  141. placeholder="请选择"
  142. >
  143. <el-option
  144. v-for="id in Object.keys(places)"
  145. :key="id"
  146. :label="places[id]"
  147. :value="id"
  148. />
  149. </el-select>
  150. </el-form-item>
  151. </el-form>
  152. <template #footer>
  153. <div class="dialog-footer">
  154. <el-button @click="closePlace">取 消</el-button>
  155. <el-button type="primary" @click="enterDialogPlace">确 定</el-button>
  156. </div>
  157. </template>
  158. </el-dialog>
  159. <el-dialog v-model="dialogFormVisiblePro" :before-close="closeDialogPro" title="扣分详情">
  160. <div>
  161. <el-pagination
  162. layout="total, sizes, prev, pager, next, jumper"
  163. :current-page="pagePro"
  164. :page-size="pageSizePro"
  165. :page-sizes="[10, 30, 50, 100]"
  166. :style="{float:'right',padding:'20px'}"
  167. :total="totalPro"
  168. @current-change="handleCurrentChangePro"
  169. @size-change="handleSizeChangePro"
  170. />
  171. <el-table
  172. ref="crudItem"
  173. border
  174. stripe
  175. style="width: 100%"
  176. tooltip-effect="dark"
  177. :data="tableDataPro"
  178. >
  179. <el-table-column label="日期" width="180">
  180. <template #default="scope">{{ formatDate(scope.row.CreatedAt) }}</template>
  181. </el-table-column>
  182. <el-table-column label="发布人" prop="oper" />
  183. <el-table-column label="站点" prop="siteName" />
  184. <el-table-column label="站点类型" prop="siteType">
  185. <template #default="scope">
  186. <dict-tag :options="dict.type.site_type" :value="scope.row.siteType" />
  187. </template>
  188. </el-table-column>
  189. <el-table-column label="已登录查阅次数" prop="count" />
  190. <el-table-column label="一类部门" prop="unitName" />
  191. <el-table-column label="扣评分" prop="integral">
  192. <template #default="scope">{{ scope.row.integral/100 }}</template>
  193. </el-table-column>
  194. <el-table-column label="处理状态" prop="status">
  195. <template #default="scope">
  196. <el-tag v-show="scope.row.status == 'Untreated'" type="warning">未处理</el-tag>
  197. <el-tag v-show="scope.row.status == 'Processed'" type="success">已处理</el-tag>
  198. </template>
  199. </el-table-column>
  200. <el-table-column label="责任部门" prop="department" />
  201. </el-table>
  202. </div>
  203. </el-dialog>
  204. </div>
  205. </template>
  206. <script>
  207. import {
  208. createUnit,
  209. deleteUnit,
  210. deleteUnitByIds,
  211. updateUnit,
  212. getUnitList, findUnit
  213. } from '@/api/unit' // 此处请自行替换地址
  214. import infoList from '@/mixins/infoList'
  215. import { getProblemInfoList } from '@/api/problemInfo'
  216. import { getUserPList } from '@/api/user'
  217. import { updateUnitUser, getUnitUserList } from '@/api/unitUser'
  218. import { getPlaceList } from '@/api/place'
  219. import { getUnitPlaceList, updateUnitPlace } from '@/api/unitPlace'
  220. export default {
  221. name: 'Unit',
  222. dicts: ['department_type'],
  223. mixins: [infoList],
  224. data() {
  225. return {
  226. listApi: getUnitList,
  227. listProApi: getProblemInfoList,
  228. dialogFormVisible: false,
  229. noticeList: false,
  230. userIds: {},
  231. placesVisible: false,
  232. places: {},
  233. placesForm: {
  234. placesId: [],
  235. unitId: '',
  236. },
  237. type: '',
  238. deleteVisible: false,
  239. multipleSelection: [],
  240. dialogFormVisiblePro: false,
  241. tableDataPro: [],
  242. pagePro: 1,
  243. totalPro: 10,
  244. pageSizePro: 10,
  245. bindUser: {
  246. },
  247. searchInfoPro: {
  248. CreatedAtStart: new Date(),
  249. CreatedAtEnd: new Date()
  250. },
  251. formData: {
  252. unitName: '',
  253. unitIntegral: 100,
  254. }
  255. }
  256. },
  257. async created() {
  258. await this.getTableData()
  259. getPlaceList({ page: 1, pageSize: 9999 }).then(res => {
  260. for (const place in res.data.list) {
  261. this.places[res.data.list[place].ID] = res.data.list[place].name
  262. }
  263. })
  264. },
  265. methods: {
  266. // 条件搜索前端看此方法
  267. onSubmit() {
  268. this.page = 1
  269. this.pageSize = 10
  270. this.getTableData()
  271. },
  272. handleSelectionChange(val) {
  273. this.multipleSelection = val
  274. },
  275. deleteRow(row) {
  276. this.$confirm('确定要删除吗?', '提示', {
  277. confirmButtonText: '确定',
  278. cancelButtonText: '取消',
  279. type: 'warning'
  280. }).then(() => {
  281. this.deleteUnit(row)
  282. })
  283. },
  284. async onDelete() {
  285. const ids = []
  286. if (this.multipleSelection.length === 0) {
  287. this.$message({
  288. type: 'warning',
  289. message: '请选择要删除的数据'
  290. })
  291. return
  292. }
  293. this.multipleSelection &&
  294. this.multipleSelection.map(item => {
  295. ids.push(item.ID)
  296. })
  297. const res = await deleteUnitByIds({ ids })
  298. if (res.code === 0) {
  299. this.$message({
  300. type: 'success',
  301. message: '删除成功'
  302. })
  303. if (this.tableData.length === ids.length && this.page > 1) {
  304. this.page--
  305. }
  306. this.deleteVisible = false
  307. this.getTableData()
  308. }
  309. },
  310. selectPlace(row) {
  311. this.unitId = row.ID
  312. getUnitPlaceList({ unitId: this.unitId }).then(res => {
  313. this.placesForm.placesId = res.data.list.map(item => item.placeId)
  314. this.placesVisible = true
  315. })
  316. },
  317. enterDialogPlace() {
  318. updateUnitPlace({ unitId: this.unitId, placeIds: this.placesForm.placesId }).then(res => {
  319. this.closePlace()
  320. })
  321. },
  322. closePlace() {
  323. this.placesForm = { placesId: [],
  324. unitId: '' }
  325. this.unitId = ''
  326. this.placesVisible = false
  327. },
  328. async selecrUser(row) {
  329. this.unitId = row.ID
  330. this.noticeList = true
  331. getUnitUserList({ unitId: this.unitId }).then(res => {
  332. this.bindUser.userList = res.data
  333. })
  334. getUserPList({ page: 1, pageSize: 9999 }).then(res => {
  335. for (const user in res.data.list) {
  336. this.userIds[res.data.list[user].uuid] = res.data.list[user].userName
  337. }
  338. })
  339. },
  340. closeSend() {
  341. this.noticeList = false
  342. this.userIds = {}
  343. this.bindUser.userList = []
  344. this.unitId = ''
  345. },
  346. saveUser() {
  347. updateUnitUser({ unitId: this.unitId, uuid: this.bindUser.userList }).then(res => {
  348. this.closeSend()
  349. })
  350. },
  351. async updateUnit(row) {
  352. const res = await findUnit({ ID: row.ID })
  353. this.formData = res.data.reunit
  354. this.type = 'update'
  355. this.dialogFormVisible = true
  356. },
  357. closeDialog() {
  358. this.dialogFormVisible = false
  359. this.formData = {
  360. unitName: '',
  361. unitIntegral: 100,
  362. }
  363. },
  364. async deleteUnit(row) {
  365. const res = await deleteUnit({ ID: row.ID })
  366. if (res.code === 0) {
  367. this.$message({
  368. type: 'success',
  369. message: '删除成功'
  370. })
  371. if (this.tableData.length === 1 && this.page > 1) {
  372. this.page--
  373. }
  374. this.getTableData()
  375. }
  376. },
  377. async enterDialog() {
  378. let res
  379. switch (this.type) {
  380. case 'create':
  381. res = await createUnit(this.formData)
  382. break
  383. case 'update':
  384. res = await updateUnit(this.formData)
  385. break
  386. default:
  387. res = await createUnit(this.formData)
  388. break
  389. }
  390. if (res.code === 0) {
  391. this.$message({
  392. type: 'success',
  393. message: '创建/更改成功'
  394. })
  395. this.closeDialog()
  396. this.getTableData()
  397. }
  398. },
  399. openDialog() {
  400. this.type = 'create'
  401. this.dialogFormVisible = true
  402. },
  403. openProDialog(row) {
  404. this.dialogFormVisiblePro = true
  405. const formatDateStr = row.period.replace(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/, '$1/$2/$3 $4:$5:$6')
  406. // 将时间格式化成 yyyy-MM-dd HH:mm:ss
  407. this.searchInfoPro.CreatedAtStart = new Date(formatDateStr)
  408. this.searchInfoPro.CreatedAtEnd = new Date()
  409. this.searchInfoPro.unitId = row.ID
  410. this.getTableDataPro()
  411. },
  412. handleSizeChangePro(val) {
  413. this.pageSizePro = val
  414. this.getTableDataPro()
  415. },
  416. handleCurrentChangePro(val) {
  417. this.pagePro = val
  418. this.getTableDataPro()
  419. },
  420. closeDialogPro() {
  421. this.dialogFormVisiblePro = false
  422. this.formData = {
  423. unitName: '',
  424. unitIntegral: 0,
  425. }
  426. },
  427. getTableDataPro(page = this.pagePro, pageSize = this.pageSizePro) {
  428. this.listProApi({ page, pageSize, ...this.searchInfoPro }).then(res => {
  429. console.log(res)
  430. if (res.code === 0) {
  431. this.tableDataPro = res.data.list
  432. this.totalPro = res.data.total
  433. this.pagePro = res.data.page
  434. this.pageSizePro = res.data.pageSize
  435. }
  436. })
  437. }
  438. },
  439. }
  440. </script>
  441. <style>
  442. </style>