index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <div class="tenant">
  3. <div class="content">
  4. <byTable
  5. :source="sourceList.data"
  6. :pagination="sourceList.pagination"
  7. :config="config"
  8. :loading="loading"
  9. :selectConfig="selectConfig"
  10. highlight-current-row
  11. :action-list="[
  12. {
  13. text: '添加交接',
  14. action: () => openModal(),
  15. },
  16. ]"
  17. @get-list="getList"
  18. >
  19. </byTable>
  20. </div>
  21. <el-dialog
  22. :title="modalType == 'add' ? '新增' : '编辑'"
  23. v-if="dialogVisible"
  24. v-model="dialogVisible"
  25. width="500"
  26. v-loading="loadingOperation"
  27. >
  28. <byForm
  29. :formConfig="formConfig"
  30. :formOption="formOption"
  31. v-model="formData.data"
  32. :rules="rules"
  33. ref="submit"
  34. >
  35. </byForm>
  36. <template #footer>
  37. <el-button @click="dialogVisible = false" size="large"
  38. >取 消</el-button
  39. >
  40. <el-button type="primary" @click="submitForm()" size="large"
  41. >确 定</el-button
  42. >
  43. </template>
  44. </el-dialog>
  45. </div>
  46. </template>
  47. <script setup>
  48. import { ElMessage, ElMessageBox } from 'element-plus'
  49. import byTable from '@/components/byTable/index'
  50. import byForm from '@/components/byForm/index'
  51. import { computed, ref } from 'vue'
  52. import Editor from '@/components/Editor/index.vue'
  53. import useUserStore from "@/store/modules/user";
  54. const { proxy } = getCurrentInstance()
  55. const loading = ref(false)
  56. const companyList = ref({})
  57. const sourceList = ref({
  58. data: [],
  59. pagination: {
  60. total: 0,
  61. pageNum: 1,
  62. pageSize: 10,
  63. corporationId: '',
  64. keyword: '',
  65. },
  66. })
  67. const selectConfig = computed(() => {
  68. return [
  69. ]
  70. })
  71. const config = computed(() => {
  72. return [
  73. {
  74. attrs: {
  75. label: '交接人',
  76. prop: 'handoverPersonName',
  77. },
  78. },
  79. {
  80. attrs: {
  81. label: '接收人',
  82. prop: 'recipientName',
  83. },
  84. },
  85. {
  86. attrs: {
  87. label: '交接时间',
  88. prop: 'createTime',
  89. },
  90. },
  91. {
  92. attrs: {
  93. label: '交接原因',
  94. prop: 'reason',
  95. },
  96. },
  97. {
  98. attrs: {
  99. label: '交接内容',
  100. prop: 'content',
  101. },
  102. render(content) {
  103. const a = content.split(',').map((item) => {
  104. return contentObj[item]
  105. })
  106. return a.join(',')
  107. },
  108. },
  109. {
  110. attrs: {
  111. label: '备注',
  112. prop: 'remark',
  113. },
  114. },
  115. ]
  116. })
  117. const contentObj = {
  118. 1: '客户信息',
  119. }
  120. const getDict = () => {
  121. proxy
  122. .post('/corporation/page', { pageNum: 1, pageSize: 999 })
  123. .then((res) => {
  124. companyList.value = res.rows.map((item) => {
  125. return {
  126. label: item.name,
  127. value: item.id,
  128. }
  129. })
  130. })
  131. }
  132. const getList = async (req) => {
  133. sourceList.value.pagination = { ...sourceList.value.pagination, ...req }
  134. loading.value = true
  135. proxy.post('/employeeHandover/page', sourceList.value.pagination).then((res) => {
  136. sourceList.value.data = res.rows
  137. sourceList.value.pagination.total = res.total
  138. setTimeout(() => {
  139. loading.value = false
  140. }, 200)
  141. })
  142. }
  143. getDict()
  144. getList()
  145. const modalType = ref('add')
  146. const dialogVisible = ref(false)
  147. const loadingOperation = ref(false)
  148. const submit = ref(null)
  149. const formData = reactive({
  150. data: {
  151. countryId: '44',
  152. },
  153. })
  154. const formOption = reactive({
  155. inline: true,
  156. labelWidth: 100,
  157. itemWidth: 100,
  158. rules: [],
  159. })
  160. const formConfig = computed(() => {
  161. return [
  162. {
  163. label: '交接信息',
  164. },
  165. {
  166. type: 'select',
  167. prop: 'handoverPersonId',
  168. label: '交接人',
  169. data: [],
  170. itemWidth: '50',
  171. },
  172. {
  173. type: 'select',
  174. prop: 'recipientId',
  175. label: '接收人',
  176. data: [],
  177. itemWidth: '50',
  178. },
  179. {
  180. type: 'input',
  181. prop: 'reason',
  182. label: '交接原因',
  183. itemType: 'textarea',
  184. placeholder: '请输入交接原因',
  185. },
  186. {
  187. type: 'checkbox',
  188. prop: 'content',
  189. label: '交接内容',
  190. data: [{
  191. label: '客户信息',
  192. value: '1',
  193. }],
  194. },
  195. {
  196. type: 'input',
  197. prop: 'remark',
  198. label: '备注',
  199. itemType: 'textarea',
  200. placeholder: '请输入备注',
  201. },
  202. ]
  203. })
  204. let rules = ref({
  205. handoverPersonId: [
  206. { required: true, message: '请选择交接人', trigger: 'blur' },
  207. ],
  208. recipientId: [
  209. { required: true, message: '请选择接收人', trigger: 'change' },
  210. ],
  211. reason: [
  212. { required: true, message: '请输入交接原因', trigger: 'blur' },
  213. ],
  214. content: [
  215. { required: true, message: '请输入交接内容', trigger: 'blur' },
  216. ],
  217. })
  218. const openModal = () => {
  219. modalType.value = 'add'
  220. formData.data = {}
  221. loadingOperation.value = false
  222. dialogVisible.value = true
  223. }
  224. const submitForm = () => {
  225. submit.value.handleSubmit(() => {
  226. loadingOperation.value = true
  227. proxy.post('/employeeHandover/add', {...formData.data,content:formData.data.content.join(',')}).then(
  228. () => {
  229. ElMessage({
  230. message: modalType.value == 'add' ? '添加成功' : '添加成功',
  231. type: 'success',
  232. })
  233. dialogVisible.value = false
  234. getList()
  235. },
  236. (err) => {
  237. console.log(err)
  238. loadingOperation.value = false
  239. }
  240. )
  241. })
  242. }
  243. let userList = ref([])
  244. const getUser = () => {
  245. proxy
  246. .get("/tenantUser/list", {
  247. pageNum: 1,
  248. pageSize: 999,
  249. tenantId: useUserStore().user.tenantId,
  250. })
  251. .then((res) => {
  252. console.log(formConfig);
  253. res.rows = res.rows.map((item) => {
  254. return {
  255. label: item.nickName,
  256. value: item.userId,
  257. };
  258. });
  259. formConfig.value[1].data = res.rows
  260. formConfig.value[2].data = res.rows
  261. });
  262. };
  263. getUser()
  264. </script>
  265. <style lang="scss" scoped>
  266. .tenant {
  267. padding: 20px;
  268. }
  269. </style>