index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <template>
  2. <template-page
  3. v-if="pageShow"
  4. ref="pageRef"
  5. :get-list="getList"
  6. :exportList="exportList"
  7. :table-attributes="tableAttributes"
  8. :table-events="tableEvents"
  9. :options-evens-group="optionsEvensGroup"
  10. :moreParameters="moreParameters"
  11. :column-parsing="columnParsing"
  12. :operation="operation()"
  13. key="pageType"
  14. >
  15. <div class="cartographer_big">
  16. <el-dialog
  17. title="设置师傅组别"
  18. width="100%"
  19. :modal="false"
  20. :visible.sync="formDialog"
  21. :before-close="handleClose"
  22. >
  23. <zj-page-container>
  24. <zj-page-fill>
  25. <div style="box-sizing: border-box; padding: 20px 20px 0 20px">
  26. <zj-form-container ref="formRef" :form-data="formData" :form-attributes="{ size: 'mini' }">
  27. <zj-form-module title="师傅组" label-width="100px" :form-data="formData" :form-items="formItems">
  28. </zj-form-module>
  29. </zj-form-container>
  30. </div>
  31. </zj-page-fill>
  32. <div style="text-align: right; box-sizing: border-box; padding: 16px 20px">
  33. <el-button size="mini" @click="handleClose">取消</el-button>
  34. <el-button size="mini" type="primary" @click="save">保存</el-button>
  35. </div>
  36. </zj-page-container>
  37. </el-dialog>
  38. </div>
  39. </template-page>
  40. </template>
  41. <script>
  42. import TemplatePage from '@/components/template/template-page-1.vue'
  43. import import_mixin from '@/components/template/import_mixin.js'
  44. import operation_mixin from '@/components/template/operation_mixin.js'
  45. import {
  46. workerTeamList,
  47. workerTeamListExport,
  48. workerTeamAdd,
  49. workerTeamUpdate,
  50. workerTeamImport,
  51. workerTeamQueryWebsitWorker
  52. } from '@/api/masterGroup.js'
  53. import { commonTemplateDownload } from '@/api/common.js'
  54. import { getWebsit } from '@/api/customerManagement.js'
  55. import { required, requiredValueMin } from '@/components/template/rules_verify.js'
  56. export default {
  57. components: { TemplatePage },
  58. mixins: [import_mixin, operation_mixin],
  59. data() {
  60. return {
  61. pageType: 'list',
  62. pageShow: true,
  63. // 表格属性
  64. tableAttributes: {
  65. // 启用勾选列
  66. selectColumn: false
  67. },
  68. // 表格事件
  69. tableEvents: {
  70. 'selection-change': this.selectionChange
  71. },
  72. // 勾选选中行
  73. recordSelected: [],
  74. /** 表单变量 */
  75. formDialog: false,
  76. formData: {
  77. assistantWorkerId: '',
  78. assistantWorkerName: '',
  79. companyWechatId: '',
  80. companyWechatName: '',
  81. masterWorkerId: '',
  82. masterWorkerName: '',
  83. status: '',
  84. websitId: ''
  85. },
  86. websitList: [],
  87. workerTeamQueryWebsitWorkerList: []
  88. }
  89. },
  90. computed: {
  91. // 事件组合
  92. optionsEvensGroup() {
  93. return [
  94. [
  95. [
  96. this.optionsEvensAuth('add', {
  97. click: this.openForm
  98. })
  99. ]
  100. ],
  101. [
  102. [
  103. this.optionsEvensAuth('import', ({ moduleName }) => {
  104. return {
  105. name: moduleName,
  106. render: () => {
  107. return this.importButton(workerTeamImport, moduleName)
  108. }
  109. }
  110. })
  111. ],
  112. [
  113. this.optionsEvensAuth('template', {
  114. click: () => {
  115. commonTemplateDownload({ name: '师傅组队导入模板.xlsx' }, `${this.$route.meta.title}`)
  116. .then(res => {
  117. this.$message({
  118. message: '下载成功',
  119. type: 'success'
  120. })
  121. })
  122. .catch(err => {
  123. this.$message.error('下载失败')
  124. })
  125. }
  126. })
  127. ]
  128. ]
  129. ]
  130. },
  131. // 更多参数
  132. moreParameters() {
  133. return []
  134. },
  135. formItems() {
  136. return [
  137. {
  138. name: 'el-select',
  139. md: 12,
  140. options: this.websitList.map(item => ({ label: item.name, value: item.websitId })),
  141. attributes: {
  142. clearable: true,
  143. filterable: true,
  144. disabled: false,
  145. placeholder: '请输入'
  146. },
  147. formItemAttributes: {
  148. label: '所属网点',
  149. prop: 'websitId',
  150. rules: [...required]
  151. },
  152. events: {
  153. change: val => {
  154. this.formData.masterWorkerId = ''
  155. this.formData.masterWorkerName = ''
  156. this.formData.assistantWorkerId = ''
  157. this.formData.assistantWorkerName = ''
  158. this.workerTeamQueryWebsitWorkerList = []
  159. if (val) {
  160. workerTeamQueryWebsitWorker({ websitId: val }).then(res => {
  161. this.workerTeamQueryWebsitWorkerList = res.data
  162. })
  163. }
  164. }
  165. }
  166. },
  167. {
  168. name: 'el-select',
  169. md: 12,
  170. options: this.workerTeamQueryWebsitWorkerList.map(item => ({
  171. label: `(${item.workerId})${item.workerName}`,
  172. value: item.workerId,
  173. disabled: item.workerId == this.formData.assistantWorkerId
  174. })),
  175. // .filter(item => item.workerId != this.formData.assistantWorkerId)
  176. attributes: {
  177. clearable: true,
  178. filterable: true,
  179. placeholder: '请输入',
  180. disabled: !this.formData.websitId
  181. },
  182. formItemAttributes: {
  183. label: '选择大工',
  184. prop: 'masterWorkerId',
  185. rules: [...required]
  186. },
  187. events: {
  188. change: val => {
  189. this.formData.masterWorkerName = this.workerTeamQueryWebsitWorkerList?.find(
  190. item => item.workerId === val
  191. )?.workerName
  192. }
  193. }
  194. },
  195. {
  196. name: 'el-select',
  197. md: 12,
  198. options: this.workerTeamQueryWebsitWorkerList.map(item => ({
  199. label: `(${item.workerId})${item.workerName}`,
  200. value: item.workerId,
  201. disabled: item.workerId == this.formData.masterWorkerId
  202. })),
  203. //.filter(item => item.workerId != this.formData.masterWorkerId)
  204. attributes: {
  205. clearable: true,
  206. filterable: true,
  207. placeholder: '请输入',
  208. disabled: !this.formData.masterWorkerId
  209. },
  210. formItemAttributes: {
  211. label: '选择小工',
  212. prop: 'assistantWorkerId',
  213. rules: [...required]
  214. },
  215. events: {
  216. change: val => {
  217. this.formData.assistantWorkerName = this.workerTeamQueryWebsitWorkerList?.find(
  218. item => item.workerId === val
  219. )?.workerName
  220. }
  221. }
  222. },
  223. {
  224. md: 12,
  225. isShow: true,
  226. name: 'el-radio',
  227. options: [
  228. { label: '有效', value: 'ON' },
  229. { label: '无效', value: 'OFF' }
  230. ],
  231. attributes: {},
  232. formItemAttributes: {
  233. label: '状态',
  234. prop: 'status',
  235. rules: [...required]
  236. }
  237. }
  238. ]
  239. }
  240. },
  241. methods: {
  242. // 列表请求函数
  243. getList: workerTeamList,
  244. // 列表导出函数
  245. exportList: workerTeamListExport,
  246. // 表格列解析渲染数据更改
  247. columnParsing(item, defaultData) {
  248. return defaultData
  249. },
  250. // 监听勾选变化
  251. selectionChange(data) {
  252. this.recordSelected = data
  253. },
  254. // 打开创建弹窗
  255. openForm() {
  256. Promise.all([getWebsit({ type: 'C', status: true })]).then(([res1]) => {
  257. this.websitList = res1.data
  258. this.formDialog = true
  259. })
  260. },
  261. // 打开详情弹窗
  262. openDetailForm(row) {
  263. Promise.all([
  264. getWebsit({ type: 'C', status: true }),
  265. workerTeamQueryWebsitWorker({ websitId: row.websitId })
  266. ]).then(([res1, res2]) => {
  267. this.websitList = res1.data
  268. this.workerTeamQueryWebsitWorkerList = res2.data
  269. this.formData = { ...row }
  270. this.formDialog = true
  271. })
  272. },
  273. handleClose() {
  274. this.$refs?.formRef?.resetFields()
  275. this.$data.formData = this.$options.data().formData
  276. this.formDialog = false
  277. },
  278. // 操作按钮
  279. operation() {
  280. return this.operationBtn({
  281. edit: {
  282. click: ({ row, index, column }) => {
  283. this.openDetailForm(row)
  284. }
  285. }
  286. })
  287. },
  288. // 保存
  289. save() {
  290. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  291. if (valid) {
  292. ;(this.formData?.id ? workerTeamUpdate : workerTeamAdd)(this.formData).then(res => {
  293. this.$message({
  294. type: 'success',
  295. message: '保存成功'
  296. })
  297. this.handleClose()
  298. this.$refs.pageRef.refreshList()
  299. })
  300. }
  301. })
  302. }
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped></style>