auditPaths-add-or-update.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <el-dialog
  3. :title="!dataForm.id ? '新增' : '修改'"
  4. :close-on-click-modal="false"
  5. :before-close="closeDialog"
  6. :visible.sync="visible"
  7. :modal="false"
  8. width="75%">
  9. <el-form :inline="true" :model="dataForm" :rules="dataRule" ref="dataForm">
  10. <div class="form-group dialog">
  11. <el-form-item label="审核路径名称" prop="pathName">
  12. <el-input v-model="dataForm.pathName" placeholder="审核路径名称"></el-input>
  13. </el-form-item>
  14. <el-form-item label="状态" prop="status">
  15. <el-select v-model="dataForm.status" placeholder="状态" style="width: 100%">
  16. <el-option
  17. v-for="item in optionsStatue"
  18. :key="item.id"
  19. :label="item.name"
  20. :value="item.id">
  21. </el-option>
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="维护人" prop="opUserName">
  25. <el-input v-model="dataForm.opUserName" disabled placeholder="维护人"></el-input>
  26. </el-form-item>
  27. <el-form-item label="维护时间" prop="opDate">
  28. <el-input v-model="dataForm.opDate" disabled placeholder="维护时间"></el-input>
  29. </el-form-item>
  30. <el-form-item label="备注" class="full" prop="remarks">
  31. <el-input v-model="dataForm.remarks" placeholder="备注"></el-input>
  32. </el-form-item>
  33. </div>
  34. </el-form>
  35. <el-button @click.prevent="addRow()" style="float: left">添加</el-button>
  36. <el-table :data="dataList" tooltip-effect="dark" border stripe style="width: 100%; margin-bottom: 20px">
  37. <el-table-column
  38. width="80PX"
  39. label="级次"
  40. type="index">
  41. </el-table-column>
  42. <el-table-column
  43. prop="levelName"
  44. header-align="center"
  45. align="center"
  46. label="路径名称">
  47. <template slot-scope="scope">
  48. <el-input v-model="scope.row.levelName" placeholder="路径名称" show-word-limit/>
  49. </template>
  50. </el-table-column>
  51. <el-table-column
  52. prop="iffixAuditUser"
  53. header-align="center"
  54. align="center"
  55. label="是否指定审批人">
  56. <template slot-scope="scope">
  57. <el-select v-model="scope.row.iffixAuditUser" placeholder="是否指定审批人" @change="changeIffixAudit(scope.row)"
  58. style="width: 100%">
  59. <el-option
  60. v-for="item in optionsiffixAudit"
  61. :key="item.id"
  62. :label="item.name"
  63. :value="item.id">
  64. </el-option>
  65. </el-select>
  66. </template>
  67. </el-table-column>
  68. <el-table-column
  69. prop="auditUserId"
  70. header-align="center"
  71. align="center"
  72. label="审核人">
  73. <template slot-scope="scope">
  74. <el-select v-model="scope.row.auditUserId" :disabled="scope.row.iffixAuditUser === 'F'"
  75. filterable multiple collapse-tags placeholder="审核人" style="width: 100%">
  76. <el-option
  77. v-for="item in optionsUsers"
  78. :key="item.userId"
  79. :label="item.actualname"
  80. :value="item.userId">
  81. </el-option>
  82. </el-select>
  83. </template>
  84. </el-table-column>
  85. <el-table-column
  86. prop="iffinalItem"
  87. header-align="center"
  88. align="center"
  89. label="是否最后一级">
  90. <template slot-scope="scope">
  91. <el-select v-model="scope.row.iffinalItem" placeholder="是否最后一级" style="width: 100%">
  92. <el-option
  93. v-for="item in optionsIfStatus"
  94. :key="item.val"
  95. :label="item.name"
  96. :value="item.val">
  97. </el-option>
  98. </el-select>
  99. </template>
  100. </el-table-column>
  101. <el-table-column
  102. prop="remarks"
  103. header-align="center"
  104. align="center"
  105. label="备注">
  106. <template slot-scope="scope">
  107. <el-input v-model="scope.row.remarks" placeholder="备注" show-word-limit/>
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. header-align="center"
  112. align="center"
  113. label="操作">
  114. <template slot-scope="scope">
  115. <el-button @click.native.prevent="deleteRow(scope.$index, dataList)" size="small">移除</el-button>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. <span slot="footer" class="dialog-footer">
  120. <el-button @click="closeDia">取消</el-button>
  121. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  122. </span>
  123. </el-dialog>
  124. </template>
  125. <script>
  126. import { addCharge, delCharge } from '@/api/system/toConfigure'
  127. export default {
  128. data () {
  129. return {
  130. dataForm: {
  131. status: 'A'
  132. },
  133. visible: false,
  134. dataRule: {},
  135. dataList: [],
  136. optionsUsers: [],
  137. optionsiffixAudit: [{
  138. id: 'S',
  139. name: '是'
  140. }, {
  141. id: 'F',
  142. name: '否'
  143. }],
  144. optionsIfStatus: [{
  145. val: 'F',
  146. name: '否'
  147. }, {
  148. val: 'T',
  149. name: '是'
  150. }],
  151. optionsStatue: [{
  152. id: 'A',
  153. name: '有效'
  154. }, {
  155. id: 'S',
  156. name: '停用'
  157. }]
  158. }
  159. },
  160. methods: {
  161. init (val) {
  162. this.optionsUsers = []
  163. this.visible = true
  164. if (typeof val !== 'undefined') {
  165. this.queryAuditPath(val)
  166. } else {
  167. this.queryUsers()
  168. }
  169. },
  170. queryUsers () {
  171. this.$http({
  172. url: this.$http.adornUrl('/sys/user/selectUser'),
  173. method: 'post',
  174. data: ({mobile: 'auditUser'})
  175. }).then(({data}) => {
  176. if (typeof data.list !== 'undefined' && data.list !== null) {
  177. if (typeof data.list.users !== 'undefined' && data.list.users !== null) {
  178. this.optionsUsers = data.list.users
  179. }
  180. }
  181. })
  182. },
  183. queryAuditPath (val) {
  184. this.$http({
  185. url: this.$http.adornUrl('/engineering/auditPaths/queryAuditPath'),
  186. method: 'post',
  187. data: ({id: val})
  188. }).then(({data}) => {
  189. if (typeof data.list !== 'undefined' && data.list !== null) {
  190. if (typeof data.list.users !== 'undefined' && data.list.users !== null) {
  191. this.optionsUsers = data.list.users
  192. }
  193. if (typeof data.list.audit !== 'undefined' && data.list.audit !== null) {
  194. this.dataForm = data.list.audit
  195. }
  196. if (typeof data.list.auditPathsLevels !== 'undefined' && data.list.auditPathsLevels !== null) {
  197. this.dataList = data.list.auditPathsLevels
  198. if (typeof data.list.auditUserIds !== 'undefined' && data.list.auditUserIds !== null) {
  199. for (let use in data.list.auditUserIds) {
  200. this.$set(this.dataList[use], 'auditUserId', data.list.auditUserIds[use])
  201. }
  202. }
  203. }
  204. }
  205. })
  206. },
  207. addRow () {
  208. let val = {
  209. levelName: null,
  210. auditUserId: null,
  211. auditUserName: null,
  212. iffixAuditUser: 'S',
  213. iffinalItem: 'T',
  214. remarks: null
  215. }
  216. this.dataList.push(val)
  217. },
  218. deleteRow (index, rows) { // 删除改行
  219. rows.splice(index, 1)
  220. },
  221. changeIffixAudit (row) {
  222. if (row.iffixAuditUser === 'F') {
  223. row.auditUserId = null
  224. row.auditUserName = null
  225. }
  226. },
  227. // 表单提交
  228. dataFormSubmit () {
  229. if (this.dataList.length === 0) {
  230. this.$message.error('请维护审批级次')
  231. return false
  232. }
  233. for (let x in this.dataList) {
  234. if (this.dataList[x].iffixAuditUser === 'S') {
  235. if (this.dataList[x].auditUserId === null || this.dataList[x].auditUserId === '' || this.dataList[x].auditUserId.length === 0) {
  236. this.$message.error('请维护第' + (Number(x) + 1) + '级的审核人')
  237. return false
  238. }
  239. }
  240. }
  241. this.$confirm(`是否提交?`, '提示', {
  242. confirmButtonText: '确定',
  243. cancelButtonText: '取消',
  244. type: 'warning'
  245. }).then(function() {
  246. let formData = new FormData()
  247. formData.append('auditPaths', JSON.stringify(this.dataForm))
  248. formData.append('auditPathsLevels', JSON.stringify(this.dataList))
  249. return delCharge(formData)
  250. }).then(() => {
  251. if (data && data.code === 0) {
  252. this.$message({
  253. message: '操作成功',
  254. type: 'success',
  255. duration: 600,
  256. onClose: () => {
  257. this.closeDia()
  258. }
  259. })
  260. } else {
  261. this.$message.error(data.msg)
  262. }
  263. })
  264. // this.$confirm(`是否提交?`, '提示', {
  265. // confirmButtonText: '确定',
  266. // cancelButtonText: '取消',
  267. // type: 'warning'
  268. // }).then(() => {
  269. // let formData = new FormData()
  270. // formData.append('auditPaths', JSON.stringify(this.dataForm))
  271. // formData.append('auditPathsLevels', JSON.stringify(this.dataList))
  272. // this.$http({
  273. // url: this.$http.adornUrl(`/engineering/auditPaths/save`),
  274. // method: 'post',
  275. // data: formData
  276. // }).then(({data}) => {
  277. // if (data && data.code === 0) {
  278. // this.$message({
  279. // message: '操作成功',
  280. // type: 'success',
  281. // duration: 600,
  282. // onClose: () => {
  283. // this.closeDia()
  284. // }
  285. // })
  286. // } else {
  287. // this.$message.error(data.msg)
  288. // }
  289. // })
  290. // })
  291. },
  292. closeDialog (done) {
  293. done()
  294. // location.reload()
  295. this.visible = false
  296. this.$emit('refreshDataList')
  297. Object.assign(this.$data, this.$options.data.call(this))
  298. },
  299. closeDia () {
  300. this.visible = false
  301. this.$emit('refreshDataList')
  302. Object.assign(this.$data, this.$options.data.call(this))
  303. }
  304. }
  305. }
  306. </script>