index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <template-page ref="pageRef" :get-list="getList" :table-attributes="tableAttributes" :table-events="tableEvents" :operationColumnWidth="80"
  3. :options-evens-group="optionsEvensGroup" :moreParameters="moreParameters" :column-parsing="columnParsing"
  4. :operation="operation" :exportList="exportList">
  5. <el-dialog title="" width="1200px" custom-class="diy-dialog" append-to-body :modal="true" :visible.sync="formDialog"
  6. :show-close="true" :close-on-click-modal="false" :modal-append-to-body="false" :before-close="formCancel">
  7. <zj-form-container ref="formRef" :form-data="formData" :styleSwitch="false">
  8. <zj-form-module :title="formDialogTitles[formDialogType]" label-width="110px" :showPackUp="false"
  9. :form-data="formData" :form-items="formItems" :disabled="formDialogType==2">
  10. </zj-form-module>
  11. </zj-form-container>
  12. <div slot="footer" class="dialog-footer">
  13. <el-button size="mini" @click="formCancel">取 消</el-button>
  14. <el-button size="mini" v-if="formDialogType !== 2" type="primary" @click="formConfirm()">提交</el-button>
  15. </div>
  16. </el-dialog>
  17. </template-page>
  18. </template>
  19. <script>
  20. import TemplatePage from '@/components/template/template-page-1.vue'
  21. import import_mixin from '@/components/template/import_mixin.js'
  22. import ImageUpload from '@/components/file-upload'
  23. import { required, mobileRequired, mobile, httpUrl, email } from '@/components/template/rules_verify.js'
  24. import { listPageV2,pageExport, getDetail, add, edit, del, getExamine } from "@/api/workOrder/rewardsPunishmentsOrder";
  25. import { getWebsit } from "@/api/customerManagement";
  26. import { getWorker } from "@/api/auxiliaryFittings/auxiliarySalesOrder";
  27. export default {
  28. components: { TemplatePage, ImageUpload },
  29. mixins: [import_mixin],
  30. data() {
  31. return {
  32. // 事件组合
  33. optionsEvensGroup: [
  34. [
  35. [
  36. {
  37. name: '新建',
  38. click: this.addData
  39. }
  40. ],
  41. ],
  42. ],
  43. // 表格属性
  44. tableAttributes: {
  45. // 启用勾选列
  46. selectColumn: false
  47. },
  48. // 表格事件
  49. tableEvents: {
  50. 'selection-change': this.selectionChange
  51. },
  52. // 勾选选中行
  53. recordSelected: [],
  54. /** 表单变量 */
  55. formDialogType: 0,
  56. formDialogTitles: ["新增","编辑", "详情"],
  57. formDialog: false,
  58. type: JSON.parse(localStorage.getItem('greemall_user')).type, //type=1商户, type=0网点
  59. formData: {
  60. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  61. websit: {},
  62. websitName: '',
  63. websitId: '',
  64. worker: {},
  65. workerId: '',
  66. workerName: '',
  67. mobile: '',
  68. idcard: '',
  69. examineProjectName: '',
  70. examineProjectId: '',
  71. examineProjectType: '',
  72. examineProjectAmount: '',
  73. examineProject: {},
  74. orderBaseId: '',
  75. fileUrl: [],
  76. remark: ''
  77. },
  78. websitList: [],
  79. workerList: [],
  80. examineList: []
  81. }
  82. },
  83. computed: {
  84. // 更多参数
  85. moreParameters() {
  86. return []
  87. },
  88. formItems() {
  89. return [{
  90. md: 12,
  91. isShow: true,
  92. name: 'el-input',
  93. attributes: { placeholder: '请输入', disabled: true },
  94. formItemAttributes: {
  95. label: '所属商户',
  96. prop: 'companyName',
  97. rules: [...required]
  98. },
  99. }, {
  100. md: 12,
  101. isShow: this.type==1,
  102. name: 'slot-component',
  103. attributes: { placeholder: '请输入网点名称',},
  104. formItemAttributes: {
  105. label: '网点名称',
  106. prop: 'websitId',
  107. rules: [...required]
  108. },
  109. render: (h, { props, onInput }) => {
  110. var { value } = props
  111. return (
  112. <el-select v-model={this.formData.websit} disabled={this.formDialogType!=0} value-key="websitId" onChange={(e)=>{
  113. this.formData.websitId = e.websitId
  114. this.formData.websitName = e.name
  115. this.formData.worker = {}
  116. this.formData.workerId = ''
  117. this.formData.workerName = ''
  118. this.formData.idcard = ''
  119. this.formData.mobile = ''
  120. this.getWorker()
  121. }} placeholder="请选择" style="width: 100%;">
  122. {
  123. this.websitList.map((item, index) => {
  124. return <el-option key={item.websitId} label={item.name} value={item}></el-option>
  125. })
  126. }
  127. </el-select>
  128. )
  129. }
  130. }, {
  131. md: 12,
  132. isShow: this.type==0,
  133. name: 'el-input',
  134. attributes: { placeholder: '请输入网点名称', disabled: true },
  135. formItemAttributes: {
  136. label: '网点名称',
  137. prop: 'websitName',
  138. rules: [...required]
  139. }
  140. }, {
  141. md: 12,
  142. isShow: true,
  143. name: 'slot-component',
  144. attributes: { placeholder: '请选择工程师',},
  145. formItemAttributes: {
  146. label: '选择工程师',
  147. prop: 'workerId',
  148. rules: [...required]
  149. },
  150. render: (h, { props, onInput }) => {
  151. var { value } = props
  152. return (
  153. <el-select v-model={this.formData.worker} disabled={this.formDialogType!=0} value-key="nickName" onChange={(e)=>{
  154. this.formData.workerId = e.userId
  155. this.formData.workerName = e.nickName
  156. this.formData.idcard = e.idCard
  157. this.formData.mobile = e.mobile
  158. }} placeholder="请选择" style="width: 100%;">
  159. {
  160. this.workerList.map((item, index) => {
  161. return <el-option key={item.userId} label={item.nickName} value={item}></el-option>
  162. })
  163. }
  164. </el-select>
  165. )
  166. }
  167. }, {
  168. md: 12,
  169. isShow: true,
  170. name: 'el-input',
  171. attributes: { placeholder: '请输入', },
  172. formItemAttributes: {
  173. label: '身份证',
  174. prop: 'idcard',
  175. rules: this.formData.idcard?[
  176. { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  177. ]:[]
  178. }
  179. }, {
  180. md: 12,
  181. isShow: true,
  182. name: 'el-input',
  183. attributes: { placeholder: '请输入', },
  184. formItemAttributes: {
  185. label: '联系电话',
  186. prop: 'mobile',
  187. rules: this.formData.mobile?[
  188. { pattern:/^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  189. ]:[]
  190. }
  191. }, {
  192. md: 12,
  193. isShow: true,
  194. name: 'slot-component',
  195. attributes: { placeholder: '请选择考核项目',},
  196. formItemAttributes: {
  197. label: '选择考核项目',
  198. prop: 'examineProjectName',
  199. rules: [...required]
  200. },
  201. render: (h, { props, onInput }) => {
  202. var { value } = props
  203. return (
  204. <el-select v-model={this.formData.examineProject} disabled={this.formDialogType!=0} value-key="name" onChange={(e)=>{
  205. this.formData.examineProjectId = e.id
  206. this.formData.examineProjectName = e.name
  207. this.formData.examineProjectType = e.type
  208. this.formData.examineProjectAmount = e.amount
  209. }} placeholder="请选择" style="width: 100%;">
  210. {
  211. this.examineList.map((item, index) => {
  212. return <el-option key={item.id} label={item.name} value={item}></el-option>
  213. })
  214. }
  215. </el-select>
  216. )
  217. }
  218. }, {
  219. md: 12,
  220. isShow: true,
  221. name: 'slot-component',
  222. attributes: { },
  223. formItemAttributes: {
  224. label: '考核类型',
  225. prop: 'examineProjectType',
  226. rules: [...required]
  227. },
  228. render: (h, { props, onInput }) => {
  229. var { value } = props
  230. return (
  231. <el-radio-group v-model={this.formData.examineProjectType}>
  232. <el-radio disabled={true} label="REWARD">奖励</el-radio>
  233. <el-radio disabled={true} label="PUNISH">惩罚</el-radio>
  234. </el-radio-group>
  235. )
  236. }
  237. }, {
  238. md: 12,
  239. isShow: true,
  240. name: 'el-input',
  241. attributes: { placeholder: '请输入', type: 'number', disabled: true },
  242. formItemAttributes: {
  243. label: '考核金额',
  244. prop: 'examineProjectAmount',
  245. rules: [...required]
  246. }
  247. }, {
  248. md: 12,
  249. isShow: true,
  250. name: 'el-input',
  251. attributes: { placeholder: '请输入'},
  252. formItemAttributes: {
  253. label: '关联工单号',
  254. prop: 'orderBaseId',
  255. rules: []
  256. }
  257. }, {
  258. md: 24,
  259. isShow: true,
  260. name: 'slot-component',
  261. formItemAttributes: {
  262. label: '附件',
  263. prop: 'fileUrl',
  264. rules: []
  265. },
  266. render: (h, { props, onInput }) => {
  267. var { value } = props
  268. return (
  269. <ImageUpload fileList={this.formData.fileUrl} limit={1} isEdit={this.formDialogType !== 2} />
  270. )
  271. }
  272. }, {
  273. md: 24,
  274. isShow: true,
  275. name: 'el-input',
  276. attributes: { placeholder: '请输入备注内容',type: "textarea", rows: 5 },
  277. formItemAttributes: {
  278. label: '备注',
  279. prop: 'remark',
  280. rules: []
  281. }
  282. }]
  283. }
  284. },
  285. created(){
  286. if(this.$route.query.id){
  287. this.openDetail(this.$route.query.id)
  288. }
  289. },
  290. methods: {
  291. // 列表请求函数
  292. getList: listPageV2,
  293. // 列表导出函数
  294. exportList: pageExport,
  295. // 表格列解析渲染数据更改
  296. columnParsing(item, defaultData) {
  297. if (item.jname === 'fileUrl') {
  298. defaultData.render = (h, { row, index, column }) => {
  299.   return (
  300.     <div style="padding:0 6px;cursor: pointer;">
  301.       {row.fileUrl ? row.fileUrl.split(",").map(url => <el-image src={url} preview-src-list={[url]} fit="fit" style="width:80px;height:80px;" />) : null}
  302.       </div>
  303.     )
  304.   }
  305. }
  306. return defaultData
  307. },
  308. // 监听勾选变化
  309. selectionChange(data) {
  310. this.recordSelected = data
  311. },
  312. // 表格操作列
  313. operation(h, { row, index, column }) {
  314. return (
  315. <div class='operation-btns'>
  316. <el-button type="text" onClick={() => {
  317. this.openDetail(row.id)
  318. }}>详情</el-button>
  319. </div>
  320. )
  321. },
  322. openDetail(id){
  323. getDetail({ id }).then(res => {
  324. Object.assign(this.formData, res.data,{
  325. fileUrl:res.data?.fileUrl ? res.data?.fileUrl?.split(",").map(item=>({url:item})) : [],
  326. worker: {workerId: res.data.workerId,nickName: res.data.workerName},
  327. websit: {websitId: res.data.websitId,websitName: res.data.websitName},
  328. examineProject: {name: res.data.examineProjectName}
  329. })
  330. this.getExamine()
  331. this.getWebsit()
  332. this.getWorker()
  333. this.formDialogType = 2
  334. this.openForm()
  335. })
  336. },
  337. getExamine(){
  338. getExamine({pageNum: 1,pageSize: -1,params: []}).then(res => {
  339. this.examineList = res.data.records
  340. })
  341. },
  342. getWebsit(){
  343. if(this.type == 0){
  344. this.formData.websitId = JSON.parse(localStorage.getItem('greemall_user')).adminWebsitId
  345. this.formData.websitName = JSON.parse(localStorage.getItem('greemall_user')).nickName
  346. }else{
  347. getWebsit({type: 'C'}).then(res => {
  348. this.websitList = res.data
  349. })
  350. }
  351. },
  352. getWorker(){
  353. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  354. this.workerList = res.data.records
  355. })
  356. },
  357. addData() {
  358. this.getExamine()
  359. this.getWebsit()
  360. this.formDialogType = 0
  361. this.openForm()
  362. },
  363. openForm() {
  364. this.formDialog = true;
  365. },
  366. formCancel() {
  367. this.$refs.formRef.$refs.inlineForm.clearValidate()
  368. this.$data.formData = this.$options.data().formData
  369. this.formDialog = false
  370. },
  371. formConfirm() {
  372. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  373. if (valid) {
  374. ([add, edit][this.formDialogType])({
  375. ...this.formData,
  376. fileUrl:this.formData.fileUrl.map(item=>item.url).join(",")
  377. }).then(res => {
  378. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  379. this.formCancel()
  380. this.$refs.pageRef.refreshList()
  381. })
  382. }
  383. })
  384. }
  385. }
  386. }
  387. </script>
  388. <style lang="scss" scoped>
  389. .tab{
  390. padding: 20px 20px 0 20px;
  391. }
  392. </style>