tab-approve.vue 12 KB

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