auditPaths-add-or-update.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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()" v-preventReClick>确定</el-button>
  122. </span>
  123. </el-dialog>
  124. </template>
  125. <script>
  126. export default {
  127. data () {
  128. return {
  129. dataForm: {
  130. status: 'A'
  131. },
  132. visible: false,
  133. dataRule: {},
  134. dataList: [],
  135. optionsUsers: [],
  136. optionsiffixAudit: [{
  137. id: 'S',
  138. name: '是'
  139. }, {
  140. id: 'F',
  141. name: '否'
  142. }],
  143. optionsIfStatus: [{
  144. val: 'F',
  145. name: '否'
  146. }, {
  147. val: 'T',
  148. name: '是'
  149. }],
  150. optionsStatue: [{
  151. id: 'A',
  152. name: '有效'
  153. }, {
  154. id: 'S',
  155. name: '停用'
  156. }]
  157. }
  158. },
  159. methods: {
  160. init (val) {
  161. this.optionsUsers = []
  162. this.visible = true
  163. if (typeof val !== 'undefined') {
  164. this.queryAuditPath(val)
  165. } else {
  166. this.queryUsers()
  167. }
  168. },
  169. queryUsers () {
  170. this.$http({
  171. url: this.$http.adornUrl('/sys/user/selectUser'),
  172. method: 'post',
  173. data: ({mobile: 'auditUser'})
  174. }).then(({data}) => {
  175. if (typeof data.list !== 'undefined' && data.list !== null) {
  176. if (typeof data.list.users !== 'undefined' && data.list.users !== null) {
  177. this.optionsUsers = data.list.users
  178. }
  179. }
  180. })
  181. },
  182. queryAuditPath (val) {
  183. this.$http({
  184. url: this.$http.adornUrl('/engineering/auditPaths/queryAuditPath'),
  185. method: 'post',
  186. data: ({id: val})
  187. }).then(({data}) => {
  188. if (typeof data.list !== 'undefined' && data.list !== null) {
  189. if (typeof data.list.users !== 'undefined' && data.list.users !== null) {
  190. this.optionsUsers = data.list.users
  191. }
  192. if (typeof data.list.audit !== 'undefined' && data.list.audit !== null) {
  193. this.dataForm = data.list.audit
  194. }
  195. if (typeof data.list.auditPathsLevels !== 'undefined' && data.list.auditPathsLevels !== null) {
  196. this.dataList = data.list.auditPathsLevels
  197. if (typeof data.list.auditUserIds !== 'undefined' && data.list.auditUserIds !== null) {
  198. for (let use in data.list.auditUserIds) {
  199. this.$set(this.dataList[use], 'auditUserId', data.list.auditUserIds[use])
  200. }
  201. }
  202. }
  203. }
  204. })
  205. },
  206. addRow () {
  207. let val = {
  208. levelName: null,
  209. auditUserId: null,
  210. auditUserName: null,
  211. iffixAuditUser: 'S',
  212. iffinalItem: 'T',
  213. remarks: null
  214. }
  215. this.dataList.push(val)
  216. },
  217. deleteRow (index, rows) { // 删除改行
  218. rows.splice(index, 1)
  219. },
  220. changeIffixAudit (row) {
  221. if (row.iffixAuditUser === 'F') {
  222. row.auditUserId = null
  223. row.auditUserName = null
  224. }
  225. },
  226. // 表单提交
  227. dataFormSubmit () {
  228. if (this.dataList.length === 0) {
  229. this.$message.error('请维护审批级次')
  230. return false
  231. }
  232. for (let x in this.dataList) {
  233. if (this.dataList[x].iffixAuditUser === 'S') {
  234. if (this.dataList[x].auditUserId === null || this.dataList[x].auditUserId === '' || this.dataList[x].auditUserId.length === 0) {
  235. this.$message.error('请维护第' + (Number(x) + 1) + '级的审核人')
  236. return false
  237. }
  238. }
  239. }
  240. this.$confirm(`是否提交?`, '提示', {
  241. confirmButtonText: '确定',
  242. cancelButtonText: '取消',
  243. type: 'warning'
  244. }).then(() => {
  245. let formData = new FormData()
  246. formData.append('auditPaths', JSON.stringify(this.dataForm))
  247. formData.append('auditPathsLevels', JSON.stringify(this.dataList))
  248. this.$http({
  249. url: this.$http.adornUrl(`/engineering/auditPaths/save`),
  250. method: 'post',
  251. data: formData
  252. }).then(({data}) => {
  253. if (data && data.code === 0) {
  254. this.$message({
  255. message: '操作成功',
  256. type: 'success',
  257. duration: 600,
  258. onClose: () => {
  259. this.closeDia()
  260. }
  261. })
  262. } else {
  263. this.$message.error(data.msg)
  264. }
  265. })
  266. })
  267. },
  268. closeDialog (done) {
  269. done()
  270. // location.reload()
  271. this.visible = false
  272. this.$emit('refreshDataList')
  273. Object.assign(this.$data, this.$options.data.call(this))
  274. },
  275. closeDia () {
  276. this.visible = false
  277. this.$emit('refreshDataList')
  278. Object.assign(this.$data, this.$options.data.call(this))
  279. }
  280. }
  281. }
  282. </script>