credential_management_function.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <div class="body-wrapper">
  3. <el-form class="form-wrapper" :inline="true" :model="formInline">
  4. <el-row>
  5. <el-col :span="8">
  6. <el-form-item label="凭证名称">
  7. <el-input v-model="formInline.voucherName" placeholder="请输入凭证名称"></el-input>
  8. </el-form-item>
  9. </el-col>
  10. <el-col :span="8">
  11. <el-form-item>
  12. <el-button type="primary" @click="onSubmit">查询</el-button>
  13. <el-button type="success" @click="handleAdd">添加凭证</el-button>
  14. </el-form-item>
  15. </el-col>
  16. </el-row>
  17. </el-form>
  18. <el-table :data="tableData" style="background: #2a2a2a;border-color: #333;">
  19. <el-table-column
  20. label="序号"
  21. type="index"
  22. :index="indexMethod">
  23. </el-table-column>
  24. <el-table-column v-for="(item, index) in columns" :key="index" :label="item.label" :prop="item.key">
  25. </el-table-column>
  26. <el-table-column
  27. label="操作"
  28. width="150">
  29. <template slot-scope="scope" style="display: inline-block">
  30. <el-button type="primary" @click="handleEdit(scope.row)" slot="reference">修改</el-button>
  31. <el-popconfirm title="确定删除吗?" @confirm="deleteRow(scope.row)">
  32. <el-button type="danger" slot="reference">删除</el-button>
  33. </el-popconfirm>
  34. </template>
  35. </el-table-column>
  36. </el-table>
  37. <div class="table-pagination">
  38. <el-pagination :background="false" layout="total, prev, pager, next" :total="total" @current-change="handlePageChange"
  39. :current-page.sync="pageNum" :page-size.sync="pageSize">
  40. </el-pagination>
  41. </div>
  42. <el-dialog
  43. :title="title"
  44. :visible.sync="dialogVisible"
  45. width="60%"
  46. custom-class="audit-dialog">
  47. <el-form ref="formLabelAlign" style="height: 100px" class="form-div" label-position="left" label-width="100px" :model="formLabelAlign">
  48. <el-form-item label="凭证ID" required>
  49. <el-input v-model="formLabelAlign.voucherId"></el-input>
  50. </el-form-item>
  51. <el-form-item label="凭证名称" required>
  52. <el-input v-model="formLabelAlign.voucherName"></el-input>
  53. </el-form-item>
  54. <el-form-item label="凭证有效期" required>
  55. <el-date-picker
  56. v-model="formLabelAlign.voucherDate"
  57. type="date"
  58. value-format="yyyy-MM-dd HH:mm:ss"
  59. placeholder="选择日期">
  60. </el-date-picker>
  61. </el-form-item>
  62. </el-form>
  63. <span slot="footer" class="dialog-footer">
  64. <el-button @click="dialogVisible = false">取 消</el-button>
  65. <el-button type="primary" @click="handleConfirm('formLabelAlign')">确 定</el-button>
  66. </span>
  67. </el-dialog>
  68. </div>
  69. </template>
  70. <script>
  71. import api from "@/api/audit.js";
  72. export default {
  73. components: {},
  74. data() {
  75. return {
  76. formInline: {
  77. voucherName: ''
  78. },
  79. columns: [
  80. {
  81. label: '凭证ID',
  82. key: 'voucherId'
  83. },
  84. {
  85. label: '凭证名称',
  86. key: 'voucherName'
  87. },
  88. {
  89. label: '有效期',
  90. key: 'voucherDate'
  91. }
  92. ],
  93. tableData: [],
  94. total: 0,
  95. pageSize: 10,
  96. pageNum: 1,
  97. dialogVisible: false,
  98. title: '',
  99. formLabelAlign: {
  100. voucherId: '',
  101. voucherName: '',
  102. voucherDate: '',
  103. }
  104. }
  105. },
  106. mounted() {
  107. this.getTableData()
  108. },
  109. watch: {
  110. },
  111. methods: {
  112. onSubmit () {
  113. this.getTableData()
  114. },
  115. indexMethod(index) {
  116. return this.pageSize * (this.pageNum - 1) + index + 1
  117. },
  118. handleEdit(row) {
  119. this.title = '修改凭证'
  120. this.formLabelAlign = row
  121. this.dialogVisible = true
  122. },
  123. handleAdd () {
  124. this.title = '添加凭证'
  125. this.formLabelAlign = {}
  126. this.dialogVisible = true
  127. },
  128. deleteRow (record) {
  129. api.deletePz({id: record.id}).then(res => {
  130. if (res.code === 200) {
  131. this.$message({
  132. message: '删除成功!',
  133. type: 'success'
  134. })
  135. this.getTableData()
  136. }
  137. })
  138. },
  139. handlePageChange() {
  140. this.getTableData()
  141. },
  142. handleConfirm(formName) {
  143. this.$refs[formName].validate((valid) => {
  144. if (valid) {
  145. let params = {...this.formLabelAlign, voucherDate: this.formLabelAlign.voucherDate.substring(0, 10) + " 23:59:59"}
  146. if (this.title === '修改凭证') {
  147. api.addPz(params).then(res => {
  148. if(res.code === 200) {
  149. this.dialogVisible = false
  150. this.$message({
  151. message: '修改成功!',
  152. type: 'success'
  153. })
  154. this.getTableData()
  155. }
  156. })
  157. } else {
  158. let params = {...this.formLabelAlign, voucherDate: this.formLabelAlign.voucherDate.substring(0, 10) + " 23:59:59"}
  159. api.addPz(params).then(res => {
  160. if(res.code === 200) {
  161. this.dialogVisible = false
  162. this.$message({
  163. message: '添加成功!',
  164. type: 'success'
  165. })
  166. this.getTableData()
  167. }
  168. })
  169. }
  170. } else {
  171. return false;
  172. }
  173. });
  174. },
  175. getTableData() {
  176. const {pageNum, pageSize} = this
  177. api.pzglListByPage({current: pageNum, size: pageSize, voucherName: this.formInline.voucherName}).then(res => {
  178. this.tableData = res.data.records || []
  179. this.total = res.data.total
  180. })
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .form-wrapper {
  187. margin-bottom: 20px;
  188. }
  189. /deep/ .el-input__inner {
  190. background: #2d3744;
  191. border: none;
  192. border-radius: 0;
  193. }
  194. /deep/ .el-select {
  195. height: 40px;
  196. .el-input__inner {
  197. height: 40px;
  198. }
  199. .el-input__prefix, .el-input__suffix {
  200. height: 40px;
  201. }
  202. /* 下面设置右侧按钮居中 */
  203. .el-input__suffix {
  204. top: 0px;
  205. display: flex;
  206. justify-content: center;
  207. align-items: center;
  208. flex-wrap: nowrap;
  209. flex-direction: row;
  210. align-content: flex-start;
  211. }
  212. /* 输入框加上上下边是 32px + 2px =34px */
  213. .el-input__icon {
  214. line-height: 0px;
  215. }
  216. }
  217. /deep/ .form-wrapper .el-button {
  218. background: linear-gradient(90deg,#0158d9,#3c97e4);
  219. width: 100px;
  220. height: 40px;
  221. }
  222. .body-wrapper {
  223. padding: 20px;
  224. background: #0c0c0c;
  225. .button-block{
  226. text-align: right;
  227. margin-bottom: 20px;
  228. }
  229. .table-pagination{
  230. text-align: right;
  231. }
  232. .search-card{
  233. margin-bottom: 20px;
  234. text-align: center;
  235. .input-wrapper{
  236. width: 36%;
  237. }
  238. }
  239. }
  240. .audit-dialog{
  241. .mg-bt{
  242. margin-bottom: 24px;
  243. }
  244. .label{
  245. text-align: right;
  246. }
  247. .form-div{
  248. /deep/ .el-input__inner{
  249. height: 35px;
  250. width: 100%;
  251. border: 1px solid #a6a5a5;
  252. color: #fff;
  253. background: #2d3744;
  254. }
  255. /deep/ .el-input__icon {
  256. line-height: 35px;
  257. }
  258. }
  259. }
  260. </style>