tab-approve.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <HcCard>
  3. <div class="hc-page-layout-box system-parameter">
  4. <HcCardItem ui="hac-card-item w-60 mr-5">
  5. <template #header>
  6. <span class="mr-2">审批类型:</span>
  7. <el-button _icon hc-btn size="small" type="primary" @click="openpriceEdit(1)">
  8. <HcIcon name="add" />
  9. </el-button>
  10. </template>
  11. <div> <span class="mt-2">审批一级科目:</span></div>
  12. <div class="hc-layout-left-box menu mt-3">
  13. <div class="hc-menu-contents-box">
  14. <el-scrollbar>
  15. <HcMenuSimple
  16. :datas="menuOptions" :keys="menuKey" :props="menusProps"
  17. :menus="contextMenu" @menuTap="contextMenuClick"
  18. @change="menuChange"
  19. />
  20. </el-scrollbar>
  21. </div>
  22. </div>
  23. </HcCardItem>
  24. <div class="hc-page-content-box">
  25. <HcCardItem ui="hac-card-item" action-size="lg">
  26. <template #header>
  27. <span class="mr-2">流程设置:</span>
  28. </template>
  29. <template #extra>
  30. <el-button size="large" type="primary" hc-btn :disabled="menuKey.length < 1" :loading="saveApprovelaoding" @click="saveApprove">
  31. <HcIcon name="save" />
  32. <span>保存</span>
  33. </el-button>
  34. </template>
  35. <div class="approve-box">
  36. <el-checkbox-group v-model="checkList" @change="handleCheckedApproveChange">
  37. <el-checkbox v-for="item in checkData" :key="item" :label="item.dictName" />
  38. </el-checkbox-group>
  39. <HcTable ref="tableRef" :column="tableColumn" :datas="tableData" ui="hc-test-drop-table" is-row-drop is-sort @row-drop="rowDropTap" @row-sort="rowSortTap" />
  40. </div>
  41. <div class="approve-box mt-4">
  42. <el-checkbox-group v-model="checkList1" @change="handleCheckedApproveChange1">
  43. <el-checkbox v-for="item in checkData" :key="item" :label="item.dictName" />
  44. </el-checkbox-group>
  45. <HcTable :column="tableColumn1" :datas="tableData1" ui="hc-test-drop-table" class="mt-4" />
  46. </div>
  47. </HcCardItem>
  48. </div>
  49. </div>
  50. </HcCard>
  51. <!-- 预算分类新增编辑弹窗 -->
  52. <HcDialog bg-color="#ffffff" widths="22rem" is-to-body :show="priceModal" :title="priceTitle" @close="priceModalClose" @save="saveparentClick">
  53. <el-form ref="formRef" :model="priceform" label-position="top" label-width="auto" size="large" :rules="formRules">
  54. <el-form-item label="一级科目名称:" prop="dictName">
  55. <el-input v-model="priceform.dictName" />
  56. </el-form-item>
  57. </el-form>
  58. </HcDialog>
  59. </template>
  60. <script setup>
  61. import { onMounted, ref, watch } from 'vue'
  62. import { getApproveList, getParentList, removeDictionary, submitApproveList, submitDictionary } from '~api/system/parameter.js'
  63. import { formValidate, getArrValue } from 'js-fast-way'
  64. const props = defineProps({
  65. cur: {
  66. type: [String, Number],
  67. default: '',
  68. },
  69. type:{
  70. type: [String, Number],
  71. default: '',
  72. },
  73. })
  74. const tabsKey = ref(props.cur)
  75. const tabsType = ref(props.type)
  76. //监听
  77. watch(() => [
  78. props.cur,
  79. props.type,
  80. ], ([key, type]) => {
  81. tabsKey.value = key
  82. tabsType.value = type
  83. })
  84. onMounted(() => {
  85. setContextMenu()
  86. getParentListData()
  87. getcheckData()
  88. })
  89. const menuItem = ref({})
  90. //获取一级科目
  91. const getParentListData = async ()=>{
  92. const { error, code, data, msg } = await getParentList({
  93. type:tabsType.value,
  94. size:1000,
  95. })
  96. if (!error && code === 200) {
  97. menuOptions.value = getArrValue(data['records'])
  98. if ( menuOptions.value.length > 0) {
  99. menuKey.value = menuOptions.value[0]?.id
  100. menuItem.value.id = menuOptions.value[0]?.id
  101. getApproveListData()
  102. }
  103. } else {
  104. menuOptions.value = []
  105. window.$message?.warning(msg)
  106. }
  107. }
  108. const checkList = ref([])
  109. const checkList1 = ref([])
  110. //左侧菜单
  111. const menuKey = ref('')
  112. const menuOptions = ref([])
  113. const menuChange = (item) => {
  114. console.log(item)
  115. menuKey.value = item?.id
  116. menuItem.value = item
  117. getApproveListData()
  118. }
  119. const getApproveListData = async ()=>{
  120. checkList.value = []
  121. checkList1.value = []
  122. const { error, code, data } = await getApproveList({
  123. id:menuKey.value,
  124. })
  125. if (!error && code === 200) {
  126. tableData.value = data?.审批岗位 || []
  127. tableData1.value = data?.抄送信息 || []
  128. if (tableData.value.length > 0) {
  129. tableData.value.forEach((ele)=>{
  130. checkList.value.push(ele.roleName)
  131. })
  132. } else {
  133. checkList.value = []
  134. }
  135. if (tableData1.value.length > 0) {
  136. tableData1.value.forEach((ele)=>{
  137. checkList1.value.push(ele.roleName)
  138. })
  139. } else {
  140. checkList1.value = []
  141. }
  142. } else {
  143. tableData.value = []
  144. tableData1.value = []
  145. }
  146. }
  147. const menusProps = ref({
  148. key: 'id',
  149. label: 'dictName',
  150. })
  151. //菜单的右键菜单
  152. const contextMenu = ref([])
  153. const setContextMenu = () => {
  154. let newArr = []
  155. newArr.push({ icon: 'draft', label: '编辑分类', key: 'edit' })
  156. newArr.push({ icon: 'delete-bin', label: '删除分类', key: 'del' })
  157. contextMenu.value = newArr
  158. }
  159. const priceTitle = ref('')
  160. const priceModal = ref(false)
  161. const openpriceEdit = (type) => {
  162. if (type === 1) {
  163. priceTitle.value = '新增分类'
  164. priceform.value = {}
  165. menuKey.value = ''
  166. } else {
  167. priceTitle.value = '编辑分类'
  168. }
  169. priceModal.value = true
  170. }
  171. const priceform = ref({})
  172. const priceModalClose = () => {
  173. priceModal.value = false
  174. }
  175. //菜单的右键菜单被点击
  176. const contextMenuClick = ({ key, item }) => {
  177. console.log(item, 'item')
  178. menuKey.value = item?.id
  179. if (key === 'edit') {
  180. openpriceEdit(2)
  181. menuKey.value = item?.id
  182. priceform.value.dictName = item.dictName
  183. } else if (key === 'del') {
  184. window?.$messageBox?.alert('您确定要删除该预算分类信息吗? 一旦注销数据将彻底清除,请谨慎操作?', '删除提醒', {
  185. showCancelButton: true,
  186. confirmButtonText: '确认注销',
  187. cancelButtonText: '取消',
  188. type: 'warning',
  189. callback: async (action) => {
  190. if (action === 'confirm') {
  191. const { error, code, msg } = await removeDictionary({
  192. ids: item?.id,
  193. })
  194. if (!error && code === 200) {
  195. window?.$message?.success('删除成功')
  196. getParentListData()
  197. } else {
  198. window?.$message?.warning(msg)
  199. }
  200. }
  201. },
  202. })
  203. }
  204. }
  205. //新增一级科目
  206. const formRef = ref(null)
  207. const formRules = {
  208. dictName: [
  209. { required: true, message: '请输入名称', trigger: 'blur' },
  210. ],
  211. }
  212. const saveparentClick = async ()=>{
  213. const res = await formValidate(formRef.value)
  214. if (res) {
  215. const { error, code, msg } = await submitDictionary({
  216. type:tabsType.value,
  217. dictName:priceform.value?.dictName,
  218. id:menuKey.value || null,
  219. })
  220. if (!error && code === 200) {
  221. window.$message?.success(msg)
  222. priceModal.value = false
  223. getParentListData()
  224. }
  225. }
  226. }
  227. const tableColumn = [
  228. { key: 'roleName', name: '审批岗位', align:'center' },
  229. ]
  230. const tableData = ref([])
  231. const tableData1 = ref([])
  232. const handleCheckedApproveChange = (val)=>{
  233. console.log(val, 'val')
  234. let tabarr = []
  235. checkData.value.forEach((item)=>{
  236. val.forEach((ele)=>{
  237. if (item.dictName === ele) {
  238. tabarr.push({ roleName:ele, roleId: item.id })
  239. }
  240. })
  241. })
  242. tableData.value = tabarr
  243. }
  244. const handleCheckedApproveChange1 = (val)=>{
  245. let tabarr = []
  246. checkData.value.forEach((item)=>{
  247. val.forEach((ele)=>{
  248. if (item.dictName === ele) {
  249. tabarr.push({ roleName:ele, roleId: item.id })
  250. }
  251. })
  252. })
  253. tableData1.value = tabarr
  254. }
  255. const tableColumn1 = [
  256. { key: 'roleName', name: '抄送信息', align:'center' },
  257. ]
  258. const checkData = ref([])
  259. const getcheckData = async ()=>{
  260. const { error, code, data, msg } = await getParentList({
  261. code:'dept_info',
  262. type:11,
  263. size:1000,
  264. })
  265. if (!error && code === 200) {
  266. checkData.value = getArrValue(data['records'])
  267. } else {
  268. checkData.value = []
  269. window.$message?.warning(msg)
  270. }
  271. }
  272. // 行拖拽
  273. const tableRef = ref(null)
  274. const rowDropTap = (rows) => {
  275. tableRef.value?.setData(rows)
  276. }
  277. // 点击排序
  278. const rowSortTap = (rows) => {
  279. tableData.value = rows
  280. }
  281. const saveApprovelaoding = ref(false)
  282. const subObj = ref({})
  283. //保存流程
  284. const saveApprove = ()=>{
  285. console.log(tableData.value, '审批岗位')
  286. console.log(tableData1.value, '抄送信息')
  287. subObj.value.approveRoleList = tableData.value
  288. subObj.value.ccRoleList = tableData1.value
  289. subObj.value.dictId = menuKey.value
  290. console.log( subObj.value, ' subObj.value')
  291. submitApprove()
  292. }
  293. const submitApprove = async ()=>{
  294. saveApprovelaoding.value = true
  295. const { error, code, msg } = await submitApproveList( subObj.value)
  296. saveApprovelaoding.value = false
  297. if (!error && code === 200) {
  298. window.$message.success(msg)
  299. }
  300. }
  301. </script>
  302. <style scoped lang="scss">
  303. .hc-page-layout-box.system-parameter {
  304. display: flex;
  305. position: relative;
  306. // height: calc(100vh - 228px);
  307. .hc-layout-left-box.menu {
  308. width: 100%;
  309. height: 100%;
  310. position: relative;
  311. background: inherit;
  312. margin-right: auto;
  313. border-radius: 0;
  314. box-shadow: none;
  315. .hc-menu-contents-box {
  316. position: relative;
  317. // padding: 0;
  318. padding-bottom: 30px;
  319. height: 100%;
  320. // height: calc(100% - 60px);
  321. }
  322. .hc-menu-simple-box {
  323. padding: 0;
  324. .item-box {
  325. box-shadow: none;
  326. padding: 8px 10px;
  327. border-radius: 4px;
  328. background: var(--el-color-primary-light-8);
  329. .label-box {
  330. color: #8c8c8c;
  331. }
  332. .menu-icon {
  333. margin-left: 20px;
  334. background: inherit;
  335. .menu-popover-icon {
  336. color: #8c8c8c;
  337. .hc-icon-i {
  338. font-size: 20px;
  339. line-height: initial;
  340. }
  341. }
  342. }
  343. }
  344. .item-box.active {
  345. background: var(--el-color-primary-light-5);
  346. .label-box {
  347. color: white;
  348. }
  349. .menu-icon .menu-popover-icon {
  350. color: white;
  351. }
  352. }
  353. }
  354. .hc-menu-header-box {
  355. position: relative;
  356. padding: 15px 18px;
  357. display: flex;
  358. align-items: center;
  359. border-bottom: 1px solid #E9E9E9;
  360. .name {
  361. flex: auto;
  362. position: relative;
  363. }
  364. }
  365. }
  366. .hc-page-content-box {
  367. flex: 1;
  368. position: relative;
  369. }
  370. }
  371. .approve-box{
  372. border: 1px dashed rgb(187, 187, 187);
  373. padding: 20px;
  374. }
  375. </style>