certificateList.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. var _this;
  2. var nowTime = new Date().getTime();
  3. var periodChart, typeChart;
  4. new Vue({
  5. el: '#app',
  6. filters: {
  7. getImgList(key){
  8. return [fileUrl+key];
  9. }
  10. },
  11. data: function() {
  12. return {
  13. queryParams: {
  14. pageNum: 1,
  15. pageSize: 10,
  16. orderByColumn: "certificateEffectiveDate",
  17. isAsc: "descending",
  18. createBy: "31"
  19. },
  20. imgUrl: '',
  21. rules: {
  22. deptId: [{
  23. required: true, message: "所属部门不能为空", trigger: "blur"
  24. }],
  25. certificateName: [{
  26. required: true, message: "证书名称不能为空", trigger: "blur"
  27. }],
  28. certificateIssueDate: [{
  29. required: true, message: "签发日期不能为空", trigger: "blur"
  30. }],
  31. },
  32. certificateList: [],
  33. allTotal: 0,
  34. open: false,
  35. title: "",
  36. cerForm: {},
  37. certificate_category: [],
  38. defaultProps: {
  39. children: 'children',
  40. label: 'label'
  41. },
  42. deptOptions: [],
  43. upHeaders: {}
  44. }
  45. },
  46. created() {
  47. _this = this;
  48. _this.imgUrl = fileUrl;
  49. _this.upHeaders = {
  50. "Authorization": "Bearer " + getCookie("tzToken")
  51. }
  52. // setFileLogin()
  53. let _obj = getUseDict("certificate_category")
  54. setTimeout(()=>{
  55. _this.certificate_category = _obj["certificate_category"];
  56. }, 500);
  57. this.getList();
  58. this.getTree();
  59. },
  60. mounted:function(){
  61. },
  62. methods: {
  63. getList(){
  64. getCertificateList(_this.queryParams).then((response) => {
  65. _this.certificateList = response.rows;
  66. _this.allTotal = response.total;
  67. })
  68. },
  69. getTree(){
  70. getDeptList().then((response) => {
  71. _this.deptOptions = response.data;
  72. })
  73. },
  74. handleQuery() {
  75. _this.queryParams.pageNum = 1;
  76. this.getList();
  77. },
  78. resetQuery() {
  79. _this.queryParams = {
  80. pageNum: 1,
  81. pageSize: 10,
  82. orderByColumn: "certificateEffectiveDate",
  83. isAsc: "descending"
  84. }
  85. this.handleQuery();
  86. },
  87. handleCurrentChange(val) {
  88. if(val != _this.queryParams.pageNum){
  89. _this.queryParams.pageNum = val;
  90. this.getList();
  91. }
  92. },
  93. handleDelete(row) {
  94. const certificateIds = row.certificateId;
  95. this.$confirm('是否确认删除证书编号为"' + certificateIds + '"的数据项?').then(function () {
  96. return DelCertificate(certificateIds);
  97. }).then(() => {
  98. this.getList();
  99. this.$message({
  100. showClose: true,
  101. message: "删除成功",
  102. type: 'success'
  103. });
  104. }).catch(() => { });
  105. },
  106. handleUpdate(row) {
  107. this.reset();
  108. var certificateId = row.certificateId;
  109. getCertificateDetail(certificateId).then(response => {
  110. _this.cerForm = response.data;
  111. _this.open = true;
  112. setTimeout(()=>{
  113. this.$refs.treeSele.setCurrentKey(_this.cerForm.deptId);
  114. },500);
  115. _this.title = "修改证书";
  116. });
  117. },
  118. handleAdd() {
  119. this.reset();
  120. _this.open = true;
  121. _this.title = "添加证书";
  122. },
  123. reset() {
  124. _this.cerForm = {
  125. certificateId: null,
  126. deptId: null,
  127. deptName: "请选择",
  128. certificateName: null,
  129. certificateIssueDate: null,
  130. certificateType: null,
  131. certificateNextDate: null,
  132. certificateEffectiveDate: null,
  133. certificateTerm: null,
  134. certificatePositve: "",
  135. certificateContent: null,
  136. certificateState: null,
  137. certificateRemarks: null,
  138. createBy: null,
  139. createTime: null,
  140. certificateCategory: '1',
  141. isRemind: '1'
  142. };
  143. },
  144. nodeClick(_e){
  145. _this.cerForm.deptName = _e.label,
  146. _this.cerForm.deptId = _e.id
  147. this.$refs.conSelect.blur();
  148. },
  149. /** 提交按钮 */
  150. submitForm() {
  151. if (_this.cerForm.certificateId != null) {
  152. updateCertificate(_this.cerForm).then(response => {
  153. this.$message({
  154. showClose: true,
  155. message: "修改成功",
  156. type: 'success'
  157. });
  158. _this.open = false;
  159. this.getList();
  160. });
  161. } else {
  162. addCertificate(_this.cerForm).then(response => {
  163. this.$message({
  164. showClose: true,
  165. message: "新增成功",
  166. type: 'success'
  167. });
  168. _this.open = false;
  169. this.getList();
  170. });
  171. }
  172. },
  173. handleAvatarSuccess(res, file) {
  174. _this.cerForm.certificatePositve = res.fileName;
  175. },
  176. beforeAvatarUpload(file) {
  177. const fileType = ["png", "jpg", "jpeg"];
  178. const isLt2M = file.size / 1024 / 1024 < 5;
  179. let fileExtension = "";
  180. if (file.name.lastIndexOf(".") > -1) {
  181. fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
  182. }
  183. isImg = fileType.some(type => {
  184. if (file.type.indexOf(type) > -1) return true;
  185. if (fileExtension && fileExtension.indexOf(type) > -1) return true;
  186. return false;
  187. });
  188. if (!isImg) {
  189. this.$message.error('上传头像图片只能是 "png", "jpg", "jpeg" 格式!');
  190. }
  191. if (!isLt2M) {
  192. this.$message.error('上传头像图片大小不能超过 5MB!');
  193. }
  194. return isImg && isLt2M;
  195. }
  196. }
  197. })