auditPaths-add-or-update.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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" v-if="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. <el-select v-model="scope.row.auditUserId" v-if="scope.row.iffixAuditUser === 'T'"
  84. filterable multiple collapse-tags placeholder="审核人" style="width: 100%">
  85. <el-option
  86. v-for="item in optionsUsers_s"
  87. :key="item.userId"
  88. :label="item.userName"
  89. :value="item.userId">
  90. </el-option>
  91. </el-select>
  92. </template>
  93. </el-table-column>
  94. <el-table-column
  95. prop="iffinalItem"
  96. header-align="center"
  97. align="center"
  98. label="是否最后一级">
  99. <template slot-scope="scope">
  100. <el-select v-model="scope.row.iffinalItem" placeholder="是否最后一级" style="width: 100%">
  101. <el-option
  102. v-for="item in optionsIfStatus"
  103. :key="item.val"
  104. :label="item.name"
  105. :value="item.val">
  106. </el-option>
  107. </el-select>
  108. </template>
  109. </el-table-column>
  110. <el-table-column
  111. prop="remarks"
  112. header-align="center"
  113. align="center"
  114. label="备注">
  115. <template slot-scope="scope">
  116. <el-input v-model="scope.row.remarks" placeholder="备注" show-word-limit/>
  117. </template>
  118. </el-table-column>
  119. <el-table-column
  120. header-align="center"
  121. align="center"
  122. label="操作">
  123. <template slot-scope="scope">
  124. <el-button @click.native.prevent="deleteRow(scope.$index, dataList)" size="small">移除</el-button>
  125. </template>
  126. </el-table-column>
  127. </el-table>
  128. <span slot="footer" class="dialog-footer">
  129. <el-button @click="closeDia">取消</el-button>
  130. <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
  131. </span>
  132. </el-dialog>
  133. </template>
  134. <script>
  135. import {addCharge,reviewer,modify} from '@/api/system/auditPaths-add-or-update'
  136. import { queryUserVal } from '@/api/warehouseBusiness/agreement'
  137. import { listUser } from '@/api/system/user'
  138. export default {
  139. data () {
  140. return {
  141. dataForm: {
  142. status: 'A',
  143. },
  144. visible: false,
  145. dataRule: {},
  146. dataList: [],
  147. optionsUsers: [],
  148. optionsUsers_s:[],
  149. optionsiffixAudit: [{
  150. id: 'T',
  151. name: '是'
  152. }, {
  153. id: 'F',
  154. name: '否'
  155. }],
  156. optionsIfStatus: [{
  157. val: 'F',
  158. name: '否'
  159. }, {
  160. val: 'T',
  161. name: '是'
  162. }],
  163. optionsStatue: [{
  164. id: 'A',
  165. name: '有效'
  166. }, {
  167. id: 'S',
  168. name: '停用'
  169. }]
  170. }
  171. },
  172. methods: {
  173. init (val) {
  174. this.optionsUsers = []
  175. this.visible = true
  176. if (typeof val !== 'undefined') {
  177. console.log(val)
  178. this.queryAuditPath(val)
  179. this.queryUsers()
  180. } else {
  181. this.queryUsers()
  182. }
  183. },
  184. queryUsers () {
  185. queryUserVal().then((response)=>{
  186. // this.contrastList.createBy = response.user.userName
  187. // this.dataForm.opUserName = response.user.userName
  188. console.log(response)
  189. this.$set(this.dataForm, "opUserName", response.user.userName);
  190. this.$set(this.dataForm, "opDate", response.date.slice(0,10));
  191. })
  192. console.log(this.dataForm)
  193. //请求所有审核人角色
  194. reviewer().then(data =>{
  195. this.optionsUsers = data
  196. console.log(data)
  197. })
  198. //请求所有用户名
  199. listUser().then(response => {
  200. this.optionsUsers_s = response.rows
  201. console.log(response.rows)
  202. })
  203. // this.$http({
  204. // url: this.$http.adornUrl('/sys/user/selectUser'),
  205. // method: 'post',
  206. // data: ({mobile: 'auditUser'})
  207. // }).then(({data}) => {
  208. // if (typeof data.list !== 'undefined' && data.list !== null) {
  209. // if (typeof data.list.users !== 'undefined' && data.list.users !== null) {
  210. // this.optionsUsers = data.list.users
  211. // }
  212. // }
  213. // })
  214. },
  215. queryAuditPath (val) {
  216. modify(val).then(res => {
  217. console.log(res)
  218. let data = res.data.data
  219. this.dataForm = data.auditPaths
  220. this.dataList = data.auditPathsLevels
  221. for (let index in this.dataList){
  222. this.dataList[index].auditUserId = data.auditUserIds[index]
  223. }
  224. })
  225. },
  226. addRow () {
  227. let val = {
  228. levelName: null,
  229. auditUserId: [],
  230. // auditUserName: null,
  231. iffixAuditUser: 'T',
  232. iffinalItem: 'T',
  233. remarks: null
  234. }
  235. this.dataList.push(val)
  236. },
  237. deleteRow (index, rows) { // 删除改行
  238. rows.splice(index, 1)
  239. },
  240. changeIffixAudit (row) {
  241. row.auditUserId = []
  242. },
  243. // 表单提交
  244. dataFormSubmit () {
  245. console.log(this.dataForm)
  246. console.log(this.dataList)
  247. if (this.dataList.length === 0) {
  248. this.$message.error('请维护审批级次')
  249. return false
  250. }
  251. for (let x in this.dataList) {
  252. if (this.dataList[x].iffixAuditUser === 'S') {
  253. if (this.dataList[x].auditUserId === null || this.dataList[x].auditUserId === '' || this.dataList[x].auditUserId.length === 0) {
  254. this.$message.error('请维护第' + (Number(x) + 1) + '级的审核人')
  255. return false
  256. }
  257. }
  258. }
  259. let formData = new FormData()
  260. formData.append('auditPaths', JSON.stringify(this.dataForm))
  261. formData.append('auditPathsLevels', JSON.stringify(this.dataList))
  262. this.$confirm(`是否提交?`, '提示', {
  263. confirmButtonText: '确定',
  264. cancelButtonText: '取消',
  265. type: 'warning'
  266. }).then(function() {
  267. return addCharge(formData)
  268. }).then((data) => {
  269. console.log(data)
  270. if (data && data.code === 200) {
  271. this.$message({
  272. message: '操作成功',
  273. type: 'success'
  274. });
  275. this.closeDia()
  276. } else {
  277. this.$message.error(data.msg)
  278. }
  279. })
  280. // this.$confirm(`是否提交?`, '提示', {
  281. // confirmButtonText: '确定',
  282. // cancelButtonText: '取消',
  283. // type: 'warning'
  284. // }).then(() => {
  285. // let formData = new FormData()
  286. // formData.append('auditPaths', JSON.stringify(this.dataForm))
  287. // formData.append('auditPathsLevels', JSON.stringify(this.dataList))
  288. // this.$http({
  289. // url: this.$http.adornUrl(`/engineering/auditPaths/save`),
  290. // method: 'post',
  291. // data: formData
  292. // }).then(({data}) => {
  293. // if (data && data.code === 0) {
  294. // this.$message({
  295. // message: '操作成功',
  296. // type: 'success',
  297. // duration: 600,
  298. // onClose: () => {
  299. // this.closeDia()
  300. // }
  301. // })
  302. // } else {
  303. // this.$message.error(data.msg)
  304. // }
  305. // })
  306. // })
  307. },
  308. closeDialog (done) {
  309. done()
  310. // location.reload()
  311. this.visible = false
  312. this.$emit('refreshDataList')
  313. Object.assign(this.$data, this.$options.data.call(this))
  314. },
  315. closeDia () {
  316. this.visible = false
  317. this.$emit('refreshDataList')
  318. Object.assign(this.$data, this.$options.data.call(this))
  319. }
  320. }
  321. }
  322. </script>