SignatureDailyDia.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. <template #footer>
  80. <span class="dialog-footer">
  81. <el-button @click="close()" icon="el-icon-circle-close">关闭</el-button>
  82. <el-button type="primary" v-if="method != 'view'" @click="doSubmit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
  83. </span>
  84. </template>
  85. </el-dialog>
  86. </div>
  87. </template>
  88. <script>
  89. import SignatureDailyService from '@/api/cw/signatureDaily/SignatureDailyService'
  90. import UpLoadComponent from '@/views/common/SignatureUpLoadComponent'
  91. export default {
  92. props: {
  93. businessId: {
  94. type: String,
  95. default: ''
  96. },
  97. formReadOnly: {
  98. type: Boolean,
  99. default: false
  100. },
  101. status: {
  102. type: String,
  103. default: ''
  104. }
  105. },
  106. data() {
  107. return {
  108. bj1: '',
  109. title: '',
  110. method: '',
  111. visible: false,
  112. loading: false,
  113. dialogFormVisible: false,
  114. inputForm: {
  115. id: '',
  116. signatureName:'',
  117. signatureType:'',
  118. number:'',
  119. createName:'',
  120. officeName:'',
  121. createTime:'',
  122. remarks: '',
  123. name: '',
  124. status: '',
  125. files: [],
  126. },
  127. keyWatch: '',
  128. }
  129. },
  130. SignatureDailyService: null,
  131. created() {
  132. this.signatureDailyService = new SignatureDailyService()
  133. },
  134. mounted() {
  135. },
  136. components: {
  137. UpLoadComponent,
  138. },
  139. computed: {
  140. bus: {
  141. get() {
  142. this.$refs.uploadComponent.setDividerName('附件')
  143. return this.businessId
  144. },
  145. set(val) {
  146. this.businessId = val
  147. },
  148. }
  149. },
  150. watch: {
  151. 'keyWatch': {
  152. handler(newVal) {
  153. if (this.commonJS.isNotEmpty(this.bus)) {
  154. this.init('', this.bus)
  155. } else {
  156. this.$nextTick(() => {
  157. this.$refs.inputForm.resetFields()
  158. })
  159. }
  160. }
  161. },
  162. 'loading': {
  163. handler(newVal) {
  164. this.$emit('changeLoading', newVal)
  165. this.$refs.uploadComponent.changeLoading(newVal)
  166. }
  167. }
  168. },
  169. methods: {
  170. getKeyWatch(keyWatch) {
  171. this.keyWatch = keyWatch
  172. },
  173. init(method, id) {
  174. this.importVisible = false
  175. this.method = method
  176. this.inputForm = {
  177. id: '',
  178. signatureName:'',
  179. signatureType:'',
  180. number:'',
  181. createName:'',
  182. officeName:'',
  183. createTime:'',
  184. remarks: '',
  185. name: '',
  186. status: '',
  187. files: [],
  188. }
  189. if (method === 'add') {
  190. this.title = `新建日常签章`
  191. } else if (method === 'edit') {
  192. this.title = '修改日常签章'
  193. } else if (method === 'view') {
  194. this.title = '查看日常签章信息'
  195. }
  196. this.inputForm.id = id
  197. this.visible = true
  198. this.loading = false
  199. this.$nextTick(() => {
  200. this.$refs.inputForm.resetFields()
  201. this.loading = true
  202. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  203. this.$refs.uploadComponent.clearUpload()
  204. this.inputForm = this.recover(this.inputForm, data)
  205. this.inputForm = JSON.parse(JSON.stringify(this.inputForm))
  206. if (this.commonJS.isEmpty(this.inputForm.createName)) {
  207. this.inputForm.createName = this.$store.state.user.name
  208. this.inputForm.officeName = this.$store.state.user.office.name
  209. }
  210. if (this.commonJS.isEmpty(this.inputForm.createTime)) {
  211. this.inputForm.createTime = this.moment(new Date()).format("YYYY-MM-DD")
  212. }
  213. if (this.commonJS.isEmpty(this.inputForm.files) || this.inputForm.files.length === 0) {
  214. this.inputForm.files = []
  215. }
  216. if (this.status === 'audit' || this.status === 'taskFormDetail') {
  217. method = 'view'
  218. }
  219. console.log('this.inputForm',this.inputForm)
  220. this.$refs.uploadComponent.newUpload(method, this.inputForm.files, 'signatureDaily')
  221. this.loading = false
  222. })
  223. })
  224. },
  225. saveForm(callback) {
  226. this.doSubmit('save', callback)
  227. },
  228. startForm(callback) {
  229. this.loading = true
  230. if (this.commonJS.isNotEmpty(this.inputForm.id)) {
  231. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  232. if (data.status !== '0' && data.status !== '1' && data.status !== '3') { // 审核状态不是“未发起”或“暂存”或“撤回”,就弹出提示
  233. this.loading = false
  234. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  235. throw new Error()
  236. } else {
  237. this.doSubmit('start', callback)
  238. }
  239. })
  240. } else {
  241. this.doSubmit('start', callback)
  242. }
  243. },
  244. async agreeForm(callback) {
  245. console.log('进入方法')
  246. this.loading = true
  247. await this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  248. if (data.status !== '2') { // status的值不等于“审核中”,就弹出提示
  249. this.loading = false
  250. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  251. throw new Error()
  252. } else {
  253. this.doSubmit('agree', callback)
  254. }
  255. })
  256. },
  257. reapplyForm(callback) {
  258. this.loading = true
  259. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  260. if (data.status !== '4') { // 审核状态不是“驳回”,就弹出提示
  261. this.loading = false
  262. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  263. throw new Error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  264. } else {
  265. this.doSubmit('reapply', callback)
  266. }
  267. })
  268. },
  269. // 表单提交
  270. async doSubmit(status, callback) {
  271. this.loading = true
  272. this.$refs['inputForm'].validate((valid) => {
  273. if (valid) {
  274. this.loading = true
  275. this.inputForm.files = this.$refs.uploadComponent.getDataList()
  276. if (this.commonJS.isEmpty(this.inputForm.files) || this.inputForm.files.length === 0) {
  277. this.loading = false
  278. this.$message.error('请上传签章附件')
  279. throw new Error()
  280. }
  281. this.signatureDailyService.saveForm(this.inputForm).then((data) => {
  282. this.$refs.inputForm.resetFields()
  283. this.close()
  284. this.$emit('refreshDataList')
  285. this.loading = false
  286. }).catch(() => {
  287. this.loading = false
  288. })
  289. } else {
  290. this.loading = false
  291. }
  292. })
  293. },
  294. close() {
  295. this.$refs.uploadComponent.clearUpload()
  296. this.$refs.inputForm.resetFields()
  297. this.inputForm = {
  298. id: '',
  299. signatureName:'',
  300. signatureType:'',
  301. number:'',
  302. createName:'',
  303. officeName:'',
  304. createTime:'',
  305. remarks: '',
  306. name: '',
  307. status: '',
  308. files: [],
  309. }
  310. this.visible = false
  311. },
  312. async updateStatusById(type, callback) {
  313. this.loading = true
  314. if (await this.$refs.uploadComponent.checkProgress()) {
  315. this.loading = false
  316. throw new Error()
  317. } else {
  318. if (type === 'reject' || type === 'reback') {
  319. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  320. if (data.status !== '2') { // status的值不等于“审核中”,就弹出提示
  321. this.loading = false
  322. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  323. throw new Error()
  324. } else {
  325. // if (type === 'agree') {
  326. // // 同意
  327. // this.inputForm.status = '5'
  328. // }
  329. if (type === 'reject') {
  330. // 驳回
  331. this.inputForm.status = '4'
  332. }
  333. if (type === 'reback') {
  334. // 撤回
  335. this.inputForm.status = '3'
  336. }
  337. if (type === 'reject' || type === 'reback') {
  338. let param = {status: this.inputForm.status, id: this.inputForm.id}
  339. this.signatureDailyService.updateStatusById(param).then(() => {
  340. this.loading = false
  341. callback()
  342. })
  343. }
  344. }
  345. })
  346. } else if (type === 'hold') {
  347. this.signatureDailyService.findById(this.inputForm.id).then((data) => {
  348. if (data.status !== '4') { // status的值不等于“驳回”就弹出提示
  349. this.loading = false
  350. this.$message.error('任务数据已发生改变或不存在,请在待办任务中确认此任务是否存在')
  351. throw new Error()
  352. } else {
  353. // 终止
  354. let param = {status: '1', id: this.inputForm.id}
  355. this.signatureDailyService.updateStatusById(param).then(() => {
  356. this.loading = false
  357. callback()
  358. })
  359. }
  360. })
  361. }
  362. }
  363. },
  364. }
  365. }
  366. </script>
  367. <style scoped>
  368. /deep/ .el-input-number .el-input__inner {
  369. text-align: left;
  370. }
  371. /deep/ .vxe-footer--row .vxe-footer--column:nth-child(1) .vxe-cell--item {
  372. font-weight:700;
  373. }
  374. </style>