123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381 |
- <template>
- <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents" :operationColumnWidth="80"
- :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
- :operation="operation" :exportList="exportList">
- <el-dialog title="" width="1200px" custom-class="diy-dialog" append-to-body :modal="true" :visible.sync="formDialog"
- :show-close="true" :close-on-click-modal="false" :modal-append-to-body="false" :before-close="formCancel">
- <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
- <zj-form-module :title="formDialogTitles[formDialogType]" label-width="110px" :showPackUp="false"
- :form-data="formData" :form-items="formItems" :disabled="formDialogType==2">
- </zj-form-module>
- </zj-form-container>
- <div slot="footer" class="dialog-footer">
- <el-button size="mini" @click="formCancel">取 消</el-button>
- <el-button size="mini" v-if="formDialogType !== 2" type="primary" @click="formConfirm()">确定</el-button>
- </div>
- </el-dialog>
- </template-page>
- </template>
- <script>
- import TemplatePage from '@/components/template/template-page-1.vue'
- import import_mixin from '@/components/template/import_mixin.js'
- import ImageUpload from '@/components/file-upload'
- import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
- import { listPageV2,pageExport, getDetail, add, edit, del, getExamine } from "@/api/workOrder/rewardsPunishmentsOrder";
- import { getWebsit } from "@/api/customerManagement";
- import { getWorker } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
- export default {
- components: { TemplatePage, ImageUpload },
- mixins: [import_mixin],
- data() {
- return {
- // 事件组合
- optionsEvensGroup: [
- [
- [
- {
- name: '新建',
- click: this.addData
- }
- ],
- ],
- ],
- // 表格属性
- tableAttributes: {
- // 启用勾选列
- selectColumn: false
- },
- // 表格事件
- tableEvents: {
- 'selection-change': this.selectionChange
- },
- // 勾选选中行
- recordSelected: [],
- /** 表单变量 */
- formDialogType: 0,
- formDialogTitles: ["新增","编辑", "详情"],
- formDialog: false,
- type: JSON.parse(localStorage.getItem('greemall_user')).type, //type=1商户, type=0网点
- formData: {
- companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
- websit: {},
- websitName: '',
- websitId: '',
- worker: {},
- workerId: '',
- workerName: '',
- mobile: '',
- idcard: '',
- examineProjectName: '',
- examineProjectId: '',
- examineProjectType: '',
- examineProjectAmount: '',
- examineProject: {},
- orderBaseId: '',
- fileUrl: [],
- remark: ''
- },
- websitList: [],
- workerList: [],
- examineList: []
- }
- },
- computed: {
- // 更多参数
- moreParameters() {
- return []
- },
- formItems() {
- return [{
- md: 12,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入', disabled: true },
- formItemAttributes: {
- label: '所属商户',
- prop: 'companyName',
- rules: [...required]
- },
- }, {
- md: 12,
- isShow: this.type==1,
- name: 'slot-component',
- attributes: { placeholder: '请输入网点名称',},
- formItemAttributes: {
- label: '网点名称',
- prop: 'websitId',
- rules: [...required]
- },
- render: (h, { props, onInput }) => {
- var { value } = props
- return (
- <el-select v-model={this.formData.websit} disabled={this.formDialogType!=0} value-key="websitId" onChange={(e)=>{
- this.formData.websitId = e.websitId
- this.formData.websitName = e.name
- this.getWorker()
- }} placeholder="请选择" style="width: 100%;">
- {
- this.websitList.map((item, index) => {
- return <el-option key={item.websitId} label={item.name} value={item}></el-option>
- })
- }
- </el-select>
- )
- }
- }, {
- md: 12,
- isShow: this.type==0,
- name: 'el-input',
- attributes: { placeholder: '请输入网点名称', disabled: true },
- formItemAttributes: {
- label: '网点名称',
- prop: 'websitName',
- rules: [...required]
- }
- }, {
- md: 12,
- isShow: true,
- name: 'slot-component',
- attributes: { placeholder: '请选择工程师',},
- formItemAttributes: {
- label: '选择工程师',
- prop: 'workerId',
- rules: [...required]
- },
- render: (h, { props, onInput }) => {
- var { value } = props
- return (
- <el-select v-model={this.formData.worker} disabled={this.formDialogType!=0} value-key="nickName" onChange={(e)=>{
- this.formData.workerId = e.userId
- this.formData.workerName = e.nickName
- this.formData.idcard = e.idCard
- this.formData.mobile = e.mobile
- }} placeholder="请选择" style="width: 100%;">
- {
- this.workerList.map((item, index) => {
- return <el-option key={item.userId} label={item.nickName} value={item}></el-option>
- })
- }
- </el-select>
- )
- }
- }, {
- md: 12,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入', },
- formItemAttributes: {
- label: '身份证',
- prop: 'idcard',
- rules: this.formData.idcard?[
- { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
- ]:[]
- }
- }, {
- md: 12,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入', },
- formItemAttributes: {
- label: '联系电话',
- prop: 'mobile',
- rules: this.formData.mobile?[
- { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
- ]:[]
- }
- }, {
- md: 12,
- isShow: true,
- name: 'slot-component',
- attributes: { placeholder: '请选择考核项目',},
- formItemAttributes: {
- label: '选择考核项目',
- prop: 'examineProjectName',
- rules: [...required]
- },
- render: (h, { props, onInput }) => {
- var { value } = props
- return (
- <el-select v-model={this.formData.examineProject} disabled={this.formDialogType!=0} value-key="name" onChange={(e)=>{
- this.formData.examineProjectId = e.id
- this.formData.examineProjectName = e.name
- this.formData.examineProjectType = e.type
- this.formData.examineProjectAmount = e.amount
- }} placeholder="请选择" style="width: 100%;">
- {
- this.examineList.map((item, index) => {
- return <el-option key={item.id} label={item.name} value={item}></el-option>
- })
- }
- </el-select>
- )
- }
- }, {
- md: 12,
- isShow: true,
- name: 'slot-component',
- attributes: { },
- formItemAttributes: {
- label: '考核类型',
- prop: 'examineProjectType',
- rules: [...required]
- },
- render: (h, { props, onInput }) => {
- var { value } = props
- return (
- <el-radio-group v-model={this.formData.examineProjectType}>
- <el-radio disabled={true} label="REWARD">奖励</el-radio>
- <el-radio disabled={true} label="PUNISH">惩罚</el-radio>
- </el-radio-group>
- )
- }
- }, {
- md: 12,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入', type: 'number', disabled: true },
- formItemAttributes: {
- label: '考核金额',
- prop: 'examineProjectAmount',
- rules: [...required]
- }
- }, {
- md: 12,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入', type: 'number'},
- formItemAttributes: {
- label: '关联工单号',
- prop: 'orderBaseId',
- rules: []
- }
- }, {
- md: 24,
- isShow: true,
- name: 'slot-component',
- formItemAttributes: {
- label: '附件',
- prop: 'fileUrl',
- rules: []
- },
- render: (h, { props, onInput }) => {
- var { value } = props
- return (
- <ImageUpload fileList={this.formData.fileUrl} limit={1} isEdit={this.formDialogType !== 2} />
- )
- }
- }, {
- md: 24,
- isShow: true,
- name: 'el-input',
- attributes: { placeholder: '请输入备注内容',type: "textarea", rows: 5 },
- formItemAttributes: {
- label: '备注',
- prop: 'remark',
- rules: []
- }
- }]
- }
- },
- created(){
- this.getExamine()
- this.getWebsit()
- },
- methods: {
- // 列表请求函数
- getList: listPageV2,
- // 列表导出函数
- exportList: pageExport,
- // 表格列解析渲染数据更改
- columnParsing(item, defaultData) {
- if (item.jname === 'fileUrl') {
- defaultData.render = (h, { row, index, column }) => {
- return (
- <div style="padding:0 6px;cursor: pointer;">
- {row.fileUrl ? row.fileUrl.split(",").map(url => <el-image src={url} preview-src-list={[url]} fit="fit" style="width:80px;height:80px;" />) : null}
- </div>
- )
- }
- }
- return defaultData
- },
- // 监听勾选变化
- selectionChange(data) {
- this.recordSelected = data
- },
- // 表格操作列
- operation(h, { row, index, column }) {
- return (
- <div class='operation-btns'>
- <el-button type="text" onClick={() => {
- getDetail({ id: row.id }).then(res => {
- Object.assign(this.formData, res.data,{
- fileUrl:res.data?.fileUrl ? res.data?.fileUrl?.split(",").map(item=>({url:item})) : [],
- worker: {workerId: row.workerId,nickName: row.workerName},
- websit: {websitId: row.websitId,websitName: row.websitName},
- examineProject: {name: row.examineProjectName}
- })
- this.getWorker()
- this.formDialogType = 2
- this.openForm()
- })
- }}>详情</el-button>
- </div>
- )
- },
- getExamine(){
- getExamine({pageNum: 1,pageSize: -1,params: []}).then(res => {
- this.examineList = res.data.records
- })
- },
- getWebsit(){
- if(this.type == 0){
- this.formData.websitId = JSON.parse(localStorage.getItem('greemall_user')).adminWebsitId
- this.formData.websitName = JSON.parse(localStorage.getItem('greemall_user')).nickName
- }else{
- getWebsit({type: 'C'}).then(res => {
- this.websitList = res.data
- })
- }
- },
- getWorker(){
- getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
- this.workerList = res.data.records
- })
- },
- addData() {
- this.formDialogType = 0
- this.openForm()
- },
- openForm() {
- this.formDialog = true;
- },
- formCancel() {
- this.$refs.formRef.$refs.inlineForm.clearValidate()
- this.$data.formData = this.$options.data().formData
- this.formDialog = false
- },
- formConfirm() {
- this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
- if (valid) {
- ([add, edit][this.formDialogType])({
- ...this.formData,
- fileUrl:this.formData.fileUrl.map(item=>item.url).join(",")
- }).then(res => {
- this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
- this.formCancel()
- this.$refs.pageRef.refreshList()
- })
- }
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .tab{
- padding: 20px 20px 0 20px;
- }
- </style>
|