SignatureDailyDia.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template xmlns:v-slot="http://www.w3.org/1999/XSL/Transform">
  2. <div>
  3. <el-dialog
  4. :title="title"
  5. :close-on-click-modal="false"
  6. draggable
  7. width="1200px"
  8. @close="close"
  9. append-to-body
  10. @keyup.enter.native="doSubmit"
  11. v-model="visible">
  12. <el-form :model="inputForm" ref="inputForm" v-loading="loading" :class="method==='view'?'readonly':''" :disabled="status === 'audit' || status === 'taskFormDetail'||method==='view'"
  13. label-width="160px" @submit.native.prevent>
  14. <el-divider content-position="left"><i class="el-icon-document"></i>
  15. 基本信息
  16. </el-divider>
  17. <el-row :gutter="15">
  18. <el-col :span="12">
  19. <el-form-item label="签章描述" prop="signatureName"
  20. :rules="[{required: true, message:'签章描述不能为空', trigger:'blur'}
  21. ]">
  22. <el-input placeholder="请填写签章描述" v-model="inputForm.signatureName" clearable></el-input>
  23. </el-form-item>
  24. </el-col>
  25. <el-col :span="12">
  26. <el-form-item label="签章编号" prop="number"
  27. :rules="[
  28. ]">
  29. <el-input :disabled="true" placeholder="签章编号自动生成" v-model="inputForm.number" clearable></el-input>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="12">
  33. <el-form-item label="签章类型" prop="signatureType"
  34. :rules="[
  35. {required: true, message:'签章类型不能为空', trigger:'change'}
  36. ]">
  37. <el-select v-model="inputForm.signatureType" placeholder="请选择" style="width:100%;" clearable>
  38. <el-option
  39. v-for="item in $dictUtils.getDictList('signature_daily')"
  40. :key="item.value"
  41. :label="item.label"
  42. :value="item.value">
  43. </el-option>
  44. </el-select>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="12">
  48. <el-form-item label="创建人" prop="createName"
  49. :rules="[
  50. ]">
  51. <el-input :disabled="true" placeholder="请填写创建人" v-model="inputForm.createName" clearable></el-input>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="12">
  55. <el-form-item label="所属部门" prop="officeName"
  56. :rules="[
  57. ]">
  58. <el-input :disabled="true" placeholder="请填写所属部门" v-model="inputForm.officeName" clearable></el-input>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="12">
  62. <el-form-item label="创建日期" prop="createTime"
  63. :rules="[
  64. ]">
  65. <el-input :disabled="true" placeholder="请填写创建日期" v-model="inputForm.createTime" clearable></el-input>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :span="24">
  69. <el-form-item label="备注" prop="remarks"
  70. :rules="[
  71. ]">
  72. <el-input maxlength="500" type="textarea" placeholder="请填写备注" v-model="inputForm.remarks" show-word-limit></el-input>
  73. </el-form-item>
  74. </el-col>
  75. </el-row>
  76. </el-form>
  77. <!-- 附件-->
  78. <UpLoadComponent ref="uploadComponent"></UpLoadComponent>
  79. <UpLoadComponent2 ref="uploadComponent2"></UpLoadComponent2>
  80. <template #footer>
  81. <span class="dialog-footer">
  82. <el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
  83. <el-button type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
  84. </span>
  85. </template>
  86. </el-dialog>
  87. </div>
  88. </template>
  89. <script>
  90. import SignatureDailyService from '@/api/cw/signatureDaily/SignatureDailyService'
  91. import UpLoadComponent from '@/views/common/SignatureUpLoadComponent'
  92. import UpLoadComponent2 from '@/views/common/SignatureUpLoadComponent'
  93. export default {
  94. props: {
  95. businessId: {
  96. type: String,
  97. default: ''
  98. },
  99. formReadOnly: {
  100. type: Boolean,
  101. default: false
  102. },
  103. status: {
  104. type: String,
  105. default: ''
  106. }
  107. },
  108. data() {
  109. return {
  110. bj1: '',
  111. title: '',
  112. method: '',
  113. visible: false,
  114. loading: false,
  115. dialogFormVisible: false,
  116. inputForm: {
  117. id: '',
  118. signatureName:'',
  119. signatureType:'',
  120. number:'',
  121. createName:'',
  122. officeName:'',
  123. createTime:'',
  124. remarks: '',
  125. name: '',
  126. status: '',
  127. files: [],
  128. signatureFiles:[]
  129. },
  130. keyWatch: '',
  131. }
  132. },
  133. SignatureDailyService: null,
  134. created() {
  135. this.signatureDailyService = new SignatureDailyService()
  136. },
  137. mounted() {
  138. },
  139. components: {
  140. UpLoadComponent,
  141. UpLoadComponent2,
  142. },
  143. computed: {
  144. bus: {
  145. get() {
  146. this.$refs.uploadComponent.setDividerName('附件')
  147. this.$refs.uploadComponent2.setDividerName('附件')
  148. return this.businessId
  149. },
  150. set(val) {
  151. this.businessId = val
  152. },
  153. }
  154. },
  155. watch: {
  156. 'keyWatch': {
  157. handler(newVal) {
  158. if (this.commonJS.isNotEmpty(this.bus)) {
  159. this.init('', this.bus)
  160. } else {
  161. this.$nextTick(() => {
  162. this.$refs.inputForm.resetFields()
  163. })
  164. }
  165. }
  166. },
  167. 'loading': {
  168. handler(newVal) {
  169. this.$emit('changeLoading', newVal)
  170. this.$refs.uploadComponent.changeLoading(newVal)
  171. this.$refs.uploadComponent2.changeLoading(newVal)
  172. }
  173. }
  174. },
  175. methods: {
  176. getKeyWatch(keyWatch) {
  177. this.keyWatch = keyWatch
  178. },
  179. init(method, id) {
  180. this.importVisible = false
  181. this.method = method
  182. this.inputForm = {
  183. id: '',
  184. signatureName:'',
  185. signatureType:'',
  186. number:'',
  187. createName:'',
  188. officeName:'',
  189. createTime:'',
  190. remarks: '',
  191. name: '',
  192. status: '',
  193. files: [],
  194. signatureFiles:[]
  195. }
  196. if (method === 'add') {
  197. this.title = `新建日常签章`
  198. } else if (method === 'edit') {
  199. this.title = '修改日常签章'
  200. } else if (method === 'view') {
  201. this.title = '查看日常签章信息'
  202. }
  203. this.inputForm.id = id
  204. this.visible = true
  205. this.loading = false
  206. this.$nextTick(() => {
  207. this.$refs.inputForm.resetFields()
  208. this.loading = true
  209. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  210. this.$refs.uploadComponent.clearUpload()
  211. this.$refs.uploadComponent2.clearUpload()
  212. this.inputForm = this.recover(this.inputForm, data)
  213. this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
  214. if (this.commonJS.isEmpty(this.inputForm.createName)) {
  215. this.inputForm.createName = this.$store.state.user.name
  216. this.inputForm.officeName = this.$store.state.user.office.name
  217. }
  218. if (this.commonJS.isEmpty(this.inputForm.createTime)) {
  219. this.inputForm.createTime = this.moment(new Date()).format("YYYY-MM-DD")
  220. }
  221. if (this.commonJS.isEmpty(this.inputForm.files) || this.inputForm.files.length === 0) {
  222. this.inputForm.files = []
  223. }
  224. if (this.status === 'audit' || this.status === 'taskFormDetail') {
  225. method = 'view'
  226. }
  227. if (this.commonJS.isEmpty(this.inputForm.signatureFiles) || this.inputForm.signatureFiles.length === 0) {
  228. this.inputForm.signatureFiles = []
  229. }
  230. console.log('this.inputForm',this.inputForm)
  231. this.$refs.uploadComponent.newUpload(method, this.inputForm.files, 'signatureDaily')
  232. this.$refs.uploadComponent2.newUpload(method, this.inputForm.signatureFiles, 'signatureDaily')
  233. this.loading = false
  234. })
  235. })
  236. },
  237. saveForm(callback) {
  238. this.doSubmit('save', callback)
  239. },
  240. startForm(callback) {
  241. this.loading = true
  242. if (this.commonJS.isNotEmpty(this.inputForm.id)) {
  243. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  244. if (data.status !== '0' && data.status !== '1' && data.status !== '3') { // 审核状态不是“未发起”或“暂存”或“撤回”,就弹出提示
  245. this.loading = false
  246. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  247. throw new Error()
  248. } else {
  249. this.doSubmit('start', callback)
  250. }
  251. })
  252. } else {
  253. this.doSubmit('start', callback)
  254. }
  255. },
  256. async agreeForm(callback) {
  257. console.log('进入方法')
  258. this.loading = true
  259. await this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  260. if (data.status !== '2') { // status的值不等于“审核中”,就弹出提示
  261. this.loading = false
  262. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  263. throw new Error()
  264. } else {
  265. this.doSubmit('agree', callback)
  266. }
  267. })
  268. },
  269. reapplyForm(callback) {
  270. this.loading = true
  271. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  272. if (data.status !== '4') { // 审核状态不是“驳回”,就弹出提示
  273. this.loading = false
  274. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  275. throw new Error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  276. } else {
  277. this.doSubmit('reapply', callback)
  278. }
  279. })
  280. },
  281. // 表单提交
  282. async doSubmit(status, callback) {
  283. this.loading = true
  284. this.$refs['inputForm'].validate((valid) => {
  285. if (valid) {
  286. this.loading = true
  287. this.inputForm.files = this.$refs.uploadComponent.getDataList()
  288. if (this.commonJS.isEmpty(this.inputForm.files) || this.inputForm.files.length === 0) {
  289. this.loading = false
  290. this.$message.error('请上传签章附件')
  291. throw new Error()
  292. }
  293. this.signatureDailyService.saveForm(this.inputForm).then((data) => {
  294. this.$refs.inputForm.resetFields()
  295. this.close()
  296. this.$emit('refreshDataList')
  297. this.loading = false
  298. }).catch(() => {
  299. this.loading = false
  300. })
  301. } else {
  302. this.loading = false
  303. }
  304. })
  305. },
  306. close() {
  307. this.$refs.uploadComponent.clearUpload()
  308. this.$refs.inputForm.resetFields()
  309. this.inputForm = {
  310. id: '',
  311. signatureName:'',
  312. signatureType:'',
  313. number:'',
  314. createName:'',
  315. officeName:'',
  316. createTime:'',
  317. remarks: '',
  318. name: '',
  319. status: '',
  320. files: [],
  321. }
  322. this.visible = false
  323. },
  324. async updateStatusById(type, callback) {
  325. this.loading = true
  326. if (await this.$refs.uploadComponent.checkProgress()) {
  327. this.loading = false
  328. throw new Error()
  329. } else {
  330. if (type === 'reject' || type === 'reback') {
  331. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  332. if (data.status !== '2') { // status的值不等于“审核中”,就弹出提示
  333. this.loading = false
  334. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  335. throw new Error()
  336. } else {
  337. // if (type === 'agree') {
  338. // // 同意
  339. // this.inputForm.status = '5'
  340. // }
  341. if (type === 'reject') {
  342. // 驳回
  343. this.inputForm.status = '4'
  344. }
  345. if (type === 'reback') {
  346. // 撤回
  347. this.inputForm.status = '3'
  348. }
  349. if (type === 'reject' || type === 'reback') {
  350. let param = {status: this.inputForm.status, id: this.inputForm.id}
  351. this.signatureDailyService.updateStatusById(param).then(() => {
  352. this.loading = false
  353. callback()
  354. })
  355. }
  356. }
  357. })
  358. } else if (type === 'hold') {
  359. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  360. if (data.status !== '4') { // status的值不等于“驳回”就弹出提示
  361. this.loading = false
  362. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  363. throw new Error()
  364. } else {
  365. // 终止
  366. let param = {status: '1', id: this.inputForm.id}
  367. this.signatureDailyService.updateStatusById(param).then(() => {
  368. this.loading = false
  369. callback()
  370. })
  371. }
  372. })
  373. }
  374. }
  375. },
  376. }
  377. }
  378. </script>
  379. <style scoped>
  380. /deep/ .el-input-number .el-input__inner {
  381. text-align: left;
  382. }
  383. /deep/ .vxe-footer--row .vxe-footer--column:nth-child(1) .vxe-cell--item {
  384. font-weight:700;
  385. }
  386. </style>