index.vue 11 KB

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