index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <d2-container>
  3. <template slot="header">
  4. <el-form size="mini"
  5. ref="form"
  6. :inline="true"
  7. class="sbutton_padding">
  8. <el-form-item label="学年"
  9. class="sbutton_margin">
  10. <el-input style="width: 140px;"
  11. v-model="search.Year"
  12. placeholder="请输入需要查询的年级"></el-input>
  13. </el-form-item>
  14. <el-form-item label="学期"
  15. class="sbutton_margin">
  16. <el-select v-model="search.Term"
  17. style="width: 140px;">
  18. <el-option v-for="item in term"
  19. :key="item.ItemValue"
  20. :label="item.ItemName"
  21. :value="parseInt(item.ItemValue)">
  22. </el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-button size="mini"
  26. type="primary"
  27. @click="initDatas()"
  28. style="margin-left:10px"
  29. @command="searchCommand"
  30. class="sbutton_margin">查 询</el-button>
  31. <el-button size="mini"
  32. type="primary"
  33. @click="clearSearch"
  34. class="sbutton_margin">重 置</el-button>
  35. <el-button size="mini"
  36. type="primary"
  37. style="margin-right:6px"
  38. @click="add()"
  39. class="sbutton_margin">添加</el-button>
  40. </el-form>
  41. </template>
  42. <el-table ref="multipleTable"
  43. :data="activities"
  44. border
  45. fit
  46. tooltip-effect="dark"
  47. style="width: 100%"
  48. @sort-change="orderby"
  49. height="100%">
  50. <el-table-column label="操作"
  51. width="180px"
  52. align="center"
  53. fixed='right'>
  54. <template slot-scope="scope">
  55. <el-button size="mini"
  56. title="编辑"
  57. type="primary"
  58. @click="edit(scope.row.Id)"
  59. icon="el-icon-edit"
  60. circle></el-button>
  61. <el-button size="mini"
  62. type="primary"
  63. title="发布"
  64. @click="publish(scope.row)"
  65. style="margin-left:5px;"
  66. icon="el-icon-s-promotion"
  67. circle></el-button>
  68. <el-button size="mini"
  69. type="info"
  70. title="详情"
  71. icon="el-icon-notebook-2"
  72. circle
  73. @click="handleDetail(scope.row)"></el-button>
  74. <el-button size="mini"
  75. type="danger"
  76. title="删除"
  77. @click="deleteduty(scope.row.Id)"
  78. style="margin-left:5px;"
  79. icon="el-icon-delete"
  80. circle></el-button>
  81. </template>
  82. </el-table-column>
  83. <el-table-column prop="Year"
  84. fit
  85. min-width="80px"
  86. label="学年"
  87. align="center"
  88. show-overflow-tooltip></el-table-column>
  89. <el-table-column prop="Term"
  90. label="学期"
  91. align="center"
  92. min-width="80px"
  93. show-overflow-tooltip
  94. :formatter="formatTerm"></el-table-column>
  95. <el-table-column prop="Title"
  96. label="标题"
  97. align="center"
  98. min-width="120px"
  99. show-overflow-tooltip></el-table-column>
  100. <el-table-column prop="Status"
  101. label="状态"
  102. align="center"
  103. min-width="80px"
  104. show-overflow-tooltip
  105. :formatter="formatStatus"></el-table-column>
  106. <el-table-column prop="CreatedTime"
  107. label="创建日期"
  108. align="center"
  109. min-width="120px"
  110. show-overflow-tooltip></el-table-column>
  111. </el-table>
  112. <dutyEditDialog ref="editDialog"
  113. @handleClose="handleCloseAdd"
  114. :dutyId="dutyId"
  115. :term="term"
  116. :statusList="statusList"
  117. width="75"></dutyEditDialog>
  118. <template slot="footer">
  119. <el-pagination style="margin: -10px;"
  120. @size-change="handleSizeChange"
  121. @current-change="handleCurrentChange"
  122. :current-page="currpage"
  123. :page-sizes="[10, 15, 20]"
  124. :page-size="size"
  125. layout="total, sizes, prev, pager, next, jumper"
  126. :total="search.page.total">
  127. </el-pagination>
  128. </template>
  129. </d2-container>
  130. </template>
  131. <script>
  132. import DutyApi from '@/api/duty'
  133. import dutyEditDialog from './components/dutyEdit'
  134. import itemDetailApi from '@/api/sysadmin/itemdetail'
  135. export default {
  136. name: 'duty',
  137. components: {
  138. dutyEditDialog
  139. },
  140. data () {
  141. return {
  142. dialogvisible: false,
  143. dutyId: -1,
  144. details: false,
  145. statusList: [],
  146. totalsize: 0,
  147. currpage: 1,
  148. size: 10,
  149. term: [],
  150. activities: [],
  151. Year: '',
  152. Title: '',
  153. Time: '',
  154. Status: '',
  155. search: {
  156. Term: '',
  157. Year: '',
  158. page: {
  159. total: 0,
  160. current: 1,
  161. size: 10
  162. }
  163. },
  164. // 列表排序
  165. Column: {
  166. Order: '',
  167. Prop: ''
  168. }
  169. }
  170. },
  171. mounted () {
  172. this.getTerm()
  173. this.getStatus()
  174. this.initDatas()
  175. },
  176. methods: {
  177. // 获取学期
  178. getTerm () {
  179. itemDetailApi.getItemDetailByItemCode({ ItemCode: 'Term' })
  180. .then(res => {
  181. this.term = res
  182. })
  183. .catch(err => {
  184. console.error(err)
  185. })
  186. },
  187. // 匹配学期
  188. formatTerm (row, column) {
  189. for (var i = 0; i < this.term.length; i++) {
  190. if (parseInt(this.term[i].ItemValue) === parseInt(row.Term)) {
  191. return this.term[i].ItemName
  192. }
  193. }
  194. },
  195. // 获取发布状态
  196. getStatus () {
  197. let _this = this
  198. itemDetailApi.getItemDetailByItemCode({ ItemCode: 'PublishStatus' })
  199. .then(res => {
  200. _this.statusList = res
  201. this.initDatas()
  202. })
  203. .catch(err => {
  204. console.error(err)
  205. })
  206. },
  207. // 匹配状态
  208. formatStatus (row, column) {
  209. for (var i = 0; i < this.statusList.length; i++) {
  210. if (parseInt(this.statusList[i].ItemValue) === parseInt(row.Status)) {
  211. return this.statusList[i].ItemName
  212. }
  213. }
  214. },
  215. // 打开 添加弹窗
  216. add () {
  217. this.$refs.editDialog.dialogvisible = true
  218. },
  219. // 打开 编辑弹窗
  220. edit (dutyId) {
  221. this.dutyId = dutyId
  222. this.$refs.editDialog.dialogvisible = true
  223. },
  224. publish (duty) {
  225. duty.Status = 1
  226. DutyApi.saveDuty(duty)
  227. },
  228. // 打开二级页面
  229. handleDetail (duty) {
  230. this.$router.push({ path: '/duty/detail', query: { duty: duty, term: this.term } })
  231. },
  232. // 添加 返回页面
  233. handleCloseAdd () {
  234. this.$refs.editDialog.dialogvisible = false
  235. this.currpage = 1
  236. this.initDatas()
  237. },
  238. // 编辑 返回页面
  239. handleCloseEdit () {
  240. this.$refs.editDialog.dialogvisible = false
  241. this.initDatas()
  242. },
  243. // 初始化列表数据,值班管理列表
  244. initDatas () {
  245. let _this = this
  246. if (!_this.CalibrationTime) {
  247. _this.CalibrationTime = []
  248. }
  249. let params = {
  250. _currentPage: this.currpage,
  251. _size: this.size,
  252. Year: this.search.Year,
  253. Term: this.search.Term,
  254. Order: this.search.Order,
  255. Prop: this.search.Prop
  256. }
  257. DutyApi.getPageList(params)
  258. .then(res => {
  259. _this.activities = res.records
  260. _this.search.page.total = res.total
  261. })
  262. },
  263. handleSizeChange (val) {
  264. this.size = val
  265. this.currpage = 1
  266. this.initDatas()
  267. },
  268. handleCurrentChange (val) {
  269. this.currpage = val
  270. this.initDatas()
  271. },
  272. jstimehandle (val) {
  273. if (val === '') {
  274. return '----'
  275. } else if (val === '0001-01-01T08:00:00+08:00') {
  276. return '----'
  277. } else if (val === '5000-01-01T23:59:59+08:00') {
  278. return '永久'
  279. } else {
  280. if (val === '0001-01-01T00:00:00Z') {
  281. return '----'
  282. } else val = val.replace('T', ' ')
  283. return val.substring(0, 19)
  284. }
  285. },
  286. count (date2) {
  287. var date1 = new Date()
  288. var date = (date2.getTime() - date1.getTime()) / (1000 * 60 * 60 * 24)/* 不用考虑闰年否 */
  289. return parseInt(date)
  290. },
  291. // 删除值班管理
  292. deleteduty (Id) {
  293. let _this = this
  294. let params = {
  295. id: Id
  296. }
  297. _this.$confirm('此操作将永久删除该值班信息, 是否继续?', '提示', {
  298. confirmButtonText: '确定',
  299. cancelButtonText: '关闭',
  300. type: 'warning'
  301. }).then(() => {
  302. DutyApi.deleteDuty(params)
  303. .then(data => {
  304. _this.initDatas()
  305. })
  306. .catch(function (error) {
  307. console.log(error)
  308. })
  309. })
  310. .catch(() => { })
  311. },
  312. // 列表排序功能
  313. orderby (column) {
  314. if (column.order === 'ascending') {
  315. this.Column.Order = 'asc'
  316. } else if (column.order === 'descending') {
  317. this.Column.Order = 'desc'
  318. }
  319. this.Column.Prop = column.prop
  320. this.initDatas()
  321. },
  322. formatDateTime (date) {
  323. var y = date.getFullYear()
  324. var m = date.getMonth() + 1
  325. m = m < 10 ? '0' + m : m
  326. var d = date.getDate()
  327. d = d < 10 ? '0' + d : d
  328. // var h = date.getHours();
  329. // var minute = date.getMinutes();
  330. // minute = minute < 10 ? ('0' + minute) : minute;
  331. return y + '-' + m + '-' + d
  332. },
  333. searchCommand (command) {
  334. if (command === 'search') {
  335. this.dialogvisible = true
  336. } else if (command === 'clear') {
  337. this.clearSearch()
  338. }
  339. },
  340. clearSearch () {
  341. this.currpage = 1
  342. this.search.Year = ''
  343. this.search.Name = ''
  344. this.search.classification = ''
  345. this.CalibrationTime = []
  346. this.initDatas()
  347. }
  348. }
  349. }
  350. </script>
  351. <style lang="scss">
  352. .el-pagination {
  353. margin: 1rem 0 2rem;
  354. text-align: right;
  355. }
  356. .plab {
  357. font-size: 13px;
  358. color: #999;
  359. }
  360. </style>