index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  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.getWorker()
  116. }} placeholder="请选择" style="width: 100%;">
  117. {
  118. this.websitList.map((item, index) => {
  119. return <el-option key={item.websitId} label={item.name} value={item}></el-option>
  120. })
  121. }
  122. </el-select>
  123. )
  124. }
  125. }, {
  126. md: 12,
  127. isShow: this.type==0,
  128. name: 'el-input',
  129. attributes: { placeholder: '请输入网点名称', disabled: true },
  130. formItemAttributes: {
  131. label: '网点名称',
  132. prop: 'websitName',
  133. rules: [...required]
  134. }
  135. }, {
  136. md: 12,
  137. isShow: true,
  138. name: 'slot-component',
  139. attributes: { placeholder: '请选择工程师',},
  140. formItemAttributes: {
  141. label: '选择工程师',
  142. prop: 'workerId',
  143. rules: [...required]
  144. },
  145. render: (h, { props, onInput }) => {
  146. var { value } = props
  147. return (
  148. <el-select v-model={this.formData.worker} disabled={this.formDialogType!=0} value-key="nickName" onChange={(e)=>{
  149. this.formData.workerId = e.userId
  150. this.formData.workerName = e.nickName
  151. this.formData.idcard = e.idCard
  152. this.formData.mobile = e.mobile
  153. }} placeholder="请选择" style="width: 100%;">
  154. {
  155. this.workerList.map((item, index) => {
  156. return <el-option key={item.userId} label={item.nickName} value={item}></el-option>
  157. })
  158. }
  159. </el-select>
  160. )
  161. }
  162. }, {
  163. md: 12,
  164. isShow: true,
  165. name: 'el-input',
  166. attributes: { placeholder: '请输入', },
  167. formItemAttributes: {
  168. label: '身份证',
  169. prop: 'idcard',
  170. rules: this.formData.idcard?[
  171. { pattern:/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/, message: '身份证号格式不正确', trigger: 'blur' }
  172. ]:[]
  173. }
  174. }, {
  175. md: 12,
  176. isShow: true,
  177. name: 'el-input',
  178. attributes: { placeholder: '请输入', },
  179. formItemAttributes: {
  180. label: '联系电话',
  181. prop: 'mobile',
  182. rules: this.formData.mobile?[
  183. { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  184. ]:[]
  185. }
  186. }, {
  187. md: 12,
  188. isShow: true,
  189. name: 'slot-component',
  190. attributes: { placeholder: '请选择考核项目',},
  191. formItemAttributes: {
  192. label: '选择考核项目',
  193. prop: 'examineProjectName',
  194. rules: [...required]
  195. },
  196. render: (h, { props, onInput }) => {
  197. var { value } = props
  198. return (
  199. <el-select v-model={this.formData.examineProject} disabled={this.formDialogType!=0} value-key="name" onChange={(e)=>{
  200. this.formData.examineProjectId = e.id
  201. this.formData.examineProjectName = e.name
  202. this.formData.examineProjectType = e.type
  203. this.formData.examineProjectAmount = e.amount
  204. }} placeholder="请选择" style="width: 100%;">
  205. {
  206. this.examineList.map((item, index) => {
  207. return <el-option key={item.id} label={item.name} value={item}></el-option>
  208. })
  209. }
  210. </el-select>
  211. )
  212. }
  213. }, {
  214. md: 12,
  215. isShow: true,
  216. name: 'slot-component',
  217. attributes: { },
  218. formItemAttributes: {
  219. label: '考核类型',
  220. prop: 'examineProjectType',
  221. rules: [...required]
  222. },
  223. render: (h, { props, onInput }) => {
  224. var { value } = props
  225. return (
  226. <el-radio-group v-model={this.formData.examineProjectType}>
  227. <el-radio disabled={true} label="REWARD">奖励</el-radio>
  228. <el-radio disabled={true} label="PUNISH">惩罚</el-radio>
  229. </el-radio-group>
  230. )
  231. }
  232. }, {
  233. md: 12,
  234. isShow: true,
  235. name: 'el-input',
  236. attributes: { placeholder: '请输入', type: 'number', disabled: true },
  237. formItemAttributes: {
  238. label: '考核金额',
  239. prop: 'examineProjectAmount',
  240. rules: [...required]
  241. }
  242. }, {
  243. md: 12,
  244. isShow: true,
  245. name: 'el-input',
  246. attributes: { placeholder: '请输入', type: 'number'},
  247. formItemAttributes: {
  248. label: '关联工单号',
  249. prop: 'orderBaseId',
  250. rules: []
  251. }
  252. }, {
  253. md: 24,
  254. isShow: true,
  255. name: 'slot-component',
  256. formItemAttributes: {
  257. label: '附件',
  258. prop: 'fileUrl',
  259. rules: []
  260. },
  261. render: (h, { props, onInput }) => {
  262. var { value } = props
  263. return (
  264. <ImageUpload fileList={this.formData.fileUrl} limit={1} isEdit={this.formDialogType !== 2} />
  265. )
  266. }
  267. }, {
  268. md: 24,
  269. isShow: true,
  270. name: 'el-input',
  271. attributes: { placeholder: '请输入备注内容',type: "textarea", rows: 5 },
  272. formItemAttributes: {
  273. label: '备注',
  274. prop: 'remark',
  275. rules: []
  276. }
  277. }]
  278. }
  279. },
  280. created(){
  281. this.getExamine()
  282. this.getWebsit()
  283. },
  284. methods: {
  285. // 列表请求函数
  286. getList: listPageV2,
  287. // 列表导出函数
  288. exportList: pageExport,
  289. // 表格列解析渲染数据更改
  290. columnParsing(item, defaultData) {
  291. if (item.jname === 'fileUrl') {
  292. defaultData.render = (h, { row, index, column }) => {
  293.   return (
  294.     <div style="padding:0 6px;cursor: pointer;">
  295.       {row.fileUrl ? row.fileUrl.split(",").map(url => <el-image src={url} preview-src-list={[url]} fit="fit" style="width:80px;height:80px;" />) : null}
  296.       </div>
  297.     )
  298.   }
  299. }
  300. return defaultData
  301. },
  302. // 监听勾选变化
  303. selectionChange(data) {
  304. this.recordSelected = data
  305. },
  306. // 表格操作列
  307. operation(h, { row, index, column }) {
  308. return (
  309. <div class='operation-btns'>
  310. <el-button type="text" onClick={() => {
  311. getDetail({ id: row.id }).then(res => {
  312. Object.assign(this.formData, res.data,{
  313. fileUrl:res.data?.fileUrl ? res.data?.fileUrl?.split(",").map(item=>({url:item})) : [],
  314. worker: {workerId: row.workerId,nickName: row.workerName},
  315. websit: {websitId: row.websitId,websitName: row.websitName},
  316. examineProject: {name: row.examineProjectName}
  317. })
  318. this.getWorker()
  319. this.formDialogType = 2
  320. this.openForm()
  321. })
  322. }}>详情</el-button>
  323. </div>
  324. )
  325. },
  326. getExamine(){
  327. getExamine({pageNum: 1,pageSize: -1,params: []}).then(res => {
  328. this.examineList = res.data.records
  329. })
  330. },
  331. getWebsit(){
  332. if(this.type == 0){
  333. this.formData.websitId = JSON.parse(localStorage.getItem('greemall_user')).adminWebsitId
  334. this.formData.websitName = JSON.parse(localStorage.getItem('greemall_user')).nickName
  335. }else{
  336. getWebsit({type: 'C'}).then(res => {
  337. this.websitList = res.data
  338. })
  339. }
  340. },
  341. getWorker(){
  342. getWorker({pageNum: 1,pageSize: -1,params: [{param: 'b.websit_id',compare: '=',value: this.formData.websitId}]}).then(res => {
  343. this.workerList = res.data.records
  344. })
  345. },
  346. addData() {
  347. this.formDialogType = 0
  348. this.openForm()
  349. },
  350. openForm() {
  351. this.formDialog = true;
  352. },
  353. formCancel() {
  354. this.$refs.formRef.$refs.inlineForm.clearValidate()
  355. this.$data.formData = this.$options.data().formData
  356. this.formDialog = false
  357. },
  358. formConfirm() {
  359. this.$refs.formRef.validate((valid, invalidFields, errLabels) => {
  360. if (valid) {
  361. ([add, edit][this.formDialogType])({
  362. ...this.formData,
  363. fileUrl:this.formData.fileUrl.map(item=>item.url).join(",")
  364. }).then(res => {
  365. this.$message({ type: 'success', message: `${this.formDialogTitles[this.formDialogType]}成功!` })
  366. this.formCancel()
  367. this.$refs.pageRef.refreshList()
  368. })
  369. }
  370. })
  371. }
  372. }
  373. }
  374. </script>
  375. <style lang="scss" scoped>
  376. .tab{
  377. padding: 20px 20px 0 20px;
  378. }
  379. </style>