index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <el-card
  3. v-loading="loading"
  4. :body-style="{
  5. height: '100%',
  6. padding: 0,
  7. display: 'flex',
  8. 'flex-direction': 'column',
  9. }"
  10. >
  11. <el-super-search
  12. v-model="params"
  13. :size="size"
  14. :dict="dict"
  15. :columns="SearchColumns"
  16. @reset="resetList"
  17. @submit="getList({ ...page, ...params })"
  18. ></el-super-search>
  19. <div style="margin: 16px 0">
  20. <el-super-ux-table
  21. v-model="tableList"
  22. :size="size"
  23. :dict="dict"
  24. :page="page"
  25. :columns="TableColumns"
  26. :height="tableHeight"
  27. index
  28. pagination
  29. ref="tables"
  30. highlight-current-row
  31. storage-key="workSpaceSuperTable"
  32. @selection-change="(selection) => (ids = selection)"
  33. @row-click="rowSelect"
  34. @row-dblclick="doubleClick"
  35. @pagination="getList({ ...page, ...params })"
  36. >
  37. <ux-table-column fixed="right" title="操作" align="center" width="180">
  38. <template slot-scope="scope">
  39. <el-button type="text" :size="size" @click.stop="check(scope.row)"
  40. >查看</el-button
  41. >
  42. <el-button type="text" :size="size" @click.stop="audit(scope.row)"
  43. >审批</el-button
  44. >
  45. <el-button type="text" :size="size" @click.stop="reject(scope.row)"
  46. >驳回</el-button
  47. >
  48. </template>
  49. </ux-table-column>
  50. </el-super-ux-table>
  51. </div>
  52. </el-card>
  53. <!-- <div id="workSpace">
  54. <el-card style="position: relative">
  55. <el-card class="box-card" style="margin-top: 10px">
  56. <div slot="header" class="clearfix" style="line-height: 38px">
  57. <span>单据概述</span>
  58. </div>
  59. <el-table
  60. v-if="cols.length !== 0"
  61. v-loading="loading"
  62. :data="sonTableList"
  63. fit
  64. :cell-style="{ borderColor: '#c0c0c0' }"
  65. :header-cell-style="{ borderColor: '#c0c0c0' }"
  66. class="exporttable"
  67. max-height="410"
  68. border
  69. highlight-current-row
  70. style="font-size: 12px"
  71. >
  72. <el-table-column
  73. label="序号"
  74. type="index"
  75. align="center"
  76. width="50px"
  77. />
  78. <el-table-column
  79. v-for="(col, index) in cols"
  80. :prop="col.prop"
  81. :label="col.label"
  82. :width="col.width"
  83. :formatter="col.formatter"
  84. >
  85. <template slot-scope="scope">
  86. <template v-if="col.attr">
  87. <component
  88. v-if="col.attr.is === 'el-dict-tag'"
  89. v-bind="col.attr"
  90. :size="$attrs.size"
  91. :value="scope.row[col.prop]"
  92. :options="dict.type[col.attr.dictName]"
  93. ></component>
  94. </template>
  95. <template v-else>
  96. <component v-if="col.formatter" is="span">{{
  97. col.formatter(scope.row)
  98. }}</component>
  99. <component v-else is="span">{{
  100. scope.row[col.prop]
  101. }}</component>
  102. </template>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. <pagination
  107. :total="sonTotal"
  108. :page.sync="sonQuery.pageNum"
  109. :limit.sync="sonQuery.pageSize"
  110. @pagination="getDetailList(checkRow)"
  111. style="height: 32px; padding: 0 !important; flex: 1; overflow-x: auto"
  112. />
  113. </el-card>
  114. </el-card>
  115. </div> -->
  116. </template>
  117. <script>
  118. import {
  119. getWorkSpaceList,
  120. auditWork,
  121. getWorkDetailList,
  122. oaBack,
  123. } from "@/api/purchase/workSpace.js";
  124. import useColumns from "./columns";
  125. import { dicts } from "./dicts";
  126. export default {
  127. name: "workSpace",
  128. dicts: [...dicts, "oa_templete_id"],
  129. components: {
  130. ElDictTag: () => import("@/components/DictTag/index.vue"),
  131. ElSuperUxTable: () => import("@/components/super-ux-table/index.vue"),
  132. ElSuperSearch: () => import("@/components/super-search/index.vue"),
  133. },
  134. data() {
  135. const page = this.$init.page();
  136. const { SearchColumns, TableColumns, RULE } = useColumns();
  137. const params = this.$init.params(SearchColumns);
  138. return {
  139. page: page,
  140. Columns: RULE,
  141. size: "mini",
  142. SearchColumns,
  143. TableColumns,
  144. params,
  145. // queryParams: {
  146. // modelIds: [],
  147. // docSubject: "",
  148. // },
  149. loading: false,
  150. tableList: [],
  151. ids: [],
  152. sonTableList: [],
  153. sonQuery: {
  154. pageNum: 1,
  155. pageSize: 10,
  156. },
  157. sonTotal: 0,
  158. checkRow: {
  159. billCode: "",
  160. type: "",
  161. },
  162. cols: [],
  163. // 记录点击行的下标
  164. recordIndex: "",
  165. };
  166. },
  167. computed: {
  168. tableHeight: {
  169. get() {
  170. return `${
  171. this.tableList.length
  172. ? this.tableList.length > 6
  173. ? 400
  174. : this.tableList.length * 36 + 36
  175. : 120
  176. }px`;
  177. },
  178. set() {},
  179. },
  180. },
  181. created() {
  182. this.resetList();
  183. },
  184. methods: {
  185. async getList(params) {
  186. try {
  187. this.$modal.loading("加载中...");
  188. let { code, rows, total } = await getWorkSpaceList(params);
  189. if (code === 200) {
  190. this.tableList = rows;
  191. this.page.total = total;
  192. }
  193. } catch (error) {
  194. } finally {
  195. this.$modal.closeLoading();
  196. }
  197. },
  198. resetList() {
  199. this.params = this.$init.params(this.SearchColumns);
  200. this.page = this.$init.page();
  201. this.getList({ ...this.page, ...this.params });
  202. },
  203. doubleClick(row) {
  204. this.rowSelect(row);
  205. },
  206. rowSelect(row, column, event) {
  207. // this.recordIndex = this.tableList.findIndex((value, index ,arr) => {
  208. // return value.billCode == row.billCode
  209. // })
  210. // this.check(row)
  211. // 选择行存储便于子表分页
  212. this.checkRow = row;
  213. this.cols = [...this.Columns[row.type]];
  214. this.getDetailList(this.checkRow);
  215. },
  216. audits() {
  217. if (this.ids.length == 0) {
  218. this.$modal.notifyWarning("请选中至少一条数据");
  219. } else {
  220. this.$modal
  221. .confirm("确认审批选中单据?")
  222. .then(() => {
  223. this.$modal.loading("审批中...");
  224. auditWork(this.ids).then((res) => {
  225. if (res.code === 200) {
  226. this.$modal.closeLoading();
  227. this.$modal.notifySuccess("审批成功");
  228. this.getList({ ...this.page, ...this.params });
  229. this.sonTableList = [];
  230. }
  231. });
  232. })
  233. .catch(() => {
  234. this.$modal.closeLoading();
  235. this.getList({ ...this.page, ...this.params });
  236. this.sonTableList = [];
  237. });
  238. }
  239. },
  240. check(row) {
  241. console.log(row);
  242. this.$router.push({
  243. path: row.linkUrl,
  244. query: { billCode: row.billCode },
  245. });
  246. },
  247. audit(row) {
  248. this.$modal.loading("审批中...");
  249. auditWork([row])
  250. .then((res) => {
  251. if (res.code === 200) {
  252. this.$modal.closeLoading();
  253. this.$modal.notifySuccess("审批成功");
  254. this.getList({ ...this.page, ...this.params });
  255. this.sonTableList = [];
  256. }
  257. })
  258. .catch(() => {
  259. this.$modal.closeLoading();
  260. this.getList({ ...this.page, ...this.params });
  261. this.sonTableList = [];
  262. });
  263. },
  264. // 驳回
  265. reject(row) {
  266. this.$prompt(
  267. "<div>请填写驳回原因 <span style='color:#ff6262'>注:只能驳回到起草节点</span></div>",
  268. "提示",
  269. {
  270. confirmButtonText: "确定",
  271. cancelButtonText: "取消",
  272. inputPattern: /\s*\S+?/,
  273. inputErrorMessage: "驳回原因不能为空",
  274. dangerouslyUseHTMLString: true,
  275. }
  276. )
  277. .then(async ({ value }) => {
  278. try {
  279. this.$modal.loading("加载中...");
  280. let params = {
  281. checkAmount: false,
  282. fdTemplateId: row.fdTemplateId,
  283. fdId: row.fdId,
  284. billCode: row.billCode,
  285. backReason: value,
  286. };
  287. console.log(params, "params");
  288. const { msg, code } = await oaBack(params);
  289. if (code === 200) {
  290. this.$emit("success");
  291. this.$notify.success(msg);
  292. }
  293. } catch (error) {
  294. } finally {
  295. this.$modal.closeLoading();
  296. }
  297. })
  298. .catch(() => {
  299. this.$modal.closeLoading();
  300. });
  301. },
  302. // 获取单据概述列表
  303. async getDetailList(row) {
  304. try {
  305. this.loading = true;
  306. let param = {
  307. billCode: row.billCode,
  308. type: row.type,
  309. ...this.sonQuery,
  310. };
  311. let { code, rows, total } = await getWorkDetailList(param);
  312. if (code === 200) {
  313. this.sonTableList = rows;
  314. this.sonTotal = total;
  315. }
  316. } catch (error) {
  317. } finally {
  318. this.loading = false;
  319. }
  320. },
  321. },
  322. };
  323. </script>
  324. <style lang="scss" scoped>
  325. #workSpace {
  326. padding: 12px;
  327. box-sizing: border-box;
  328. overflow-y: scroll;
  329. }
  330. .btn_grooup {
  331. margin-bottom: 10px;
  332. display: flex;
  333. justify-content: flex-end;
  334. }
  335. .el-pagination {
  336. margin-top: 10px;
  337. text-align: right;
  338. }
  339. </style>
  340. <style>
  341. .exporttable {
  342. border: solid 1px #c0c0c0;
  343. }
  344. .el-table .el-table__header-wrapper th {
  345. font-size: 14px;
  346. }
  347. </style>
  348. <style scoped lang="scss">
  349. .el-card {
  350. width: calc(100% - 32px);
  351. height: calc(100vh - 32px);
  352. margin: 16px;
  353. padding: 16px;
  354. border-radius: 8px;
  355. }
  356. .el-button-group + .el-button-group {
  357. margin: 0 0 0 8px;
  358. }
  359. </style>