operate.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. <template>
  2. <el-dialog
  3. :title="operateTitle"
  4. :visible.sync="visible"
  5. :width="operateType === 'delete' ? '30%' : '50%'"
  6. :append-to-body="true"
  7. :close-on-click-modal="false"
  8. @close="onClose"
  9. >
  10. <div v-if="['update', 'replace'].includes(operateType)">
  11. <div>
  12. <div v-if="operateType === 'update'">
  13. <div class="flex-box">
  14. <div class="flex-box-title">工单跟进状态</div>
  15. <el-select v-model="formData.status" placeholder="请选择" clearable size="mini">
  16. <el-option v-for="item in followType" :key="item.value" :label="item.label" :value="item.value" />
  17. </el-select>
  18. </div>
  19. <div class="flex-box">
  20. <div class="flex-box-title">工程登录信息</div>
  21. <div>已选择{{ tableData.length || 0 }}个工程登录</div>
  22. </div>
  23. </div>
  24. </div>
  25. <div v-if="operateType === 'replace'">
  26. <div class="flex-box">
  27. <div class="flex-box-title">业务员</div>
  28. <el-select v-model="formData.serviceId" placeholder="请选择" clearable size="mini">
  29. <el-option v-for="item in salesmanList" :key="item.value" :label="item.label" :value="item.value" />
  30. </el-select>
  31. </div>
  32. <div class="flex-box">
  33. <div class="flex-box-title">备注</div>
  34. <el-input
  35. v-model="formData.remark"
  36. type="textarea"
  37. :rows="4"
  38. placeholder="请输入"
  39. :maxlength="-1"
  40. :show-word-limit="false"
  41. :autosize="{ minRows: 2, maxRows: 4 }"
  42. />
  43. </div>
  44. <div class="flex-box">
  45. <div class="flex-box-title">工程登录信息</div>
  46. <div>已选择{{ tableData.length || 0 }}个工程登录</div>
  47. </div>
  48. </div>
  49. <div>
  50. <zj-table
  51. ref="tableEl"
  52. style="margin-bottom: 20px"
  53. :is-drop="true"
  54. :columns="columns"
  55. :table-data="tableData"
  56. :table-attributes="{
  57. border: true,
  58. selectColumn: true
  59. }"
  60. :table-events="tableEvents"
  61. />
  62. <!-- <div class="fr">
  63. <el-pagination
  64. :current-page="currentPage"
  65. :page-sizes="[10, 20, 30, 50]"
  66. :page-size="10"
  67. layout="total, sizes, prev, pager, next, jumper"
  68. :total="listTotal"
  69. @size-change="handleSizeChange"
  70. @current-change="handleCurrentChange"
  71. />
  72. </div> -->
  73. </div>
  74. </div>
  75. <div v-if="operateType === 'delete'">
  76. <div class="mg">请确认是否需要删除该项目?经删除后不可恢复</div>
  77. <div>请确认是否需要删除已选择的项目?经删除后不可恢复</div>
  78. </div>
  79. <div v-if="operateType === 'apply'">
  80. <div class="mg">请确认是否需要申请修改项目跟进状态?</div>
  81. <div class="mg">申请原因</div>
  82. <div>
  83. <el-input
  84. v-model="formData.remark"
  85. type="textarea"
  86. :rows="4"
  87. placeholder="请输入"
  88. :maxlength="-1"
  89. :show-word-limit="false"
  90. :autosize="{ minRows: 2, maxRows: 4 }"
  91. />
  92. </div>
  93. </div>
  94. <div v-if="operateType === 'examine'">
  95. <el-row :gutter="20">
  96. <el-col :span="12" :offset="0"> 申请人: {{ formData.applyBy }}</el-col>
  97. <el-col :span="12" :offset="0"> 所属公司: {{ formData.applyCompany }} </el-col>
  98. </el-row>
  99. <div class="mg">申请原因</div>
  100. <div>
  101. <el-input
  102. v-model="formData.applyReason"
  103. type="textarea"
  104. :rows="4"
  105. placeholder="请输入"
  106. :maxlength="-1"
  107. :show-word-limit="false"
  108. :autosize="{ minRows: 2, maxRows: 4 }"
  109. />
  110. </div>
  111. <div class="mg">审核确认</div>
  112. <div>
  113. <el-radio-group v-model="formData.isSuccess">
  114. <el-radio
  115. v-for="item in [
  116. { label: '同意', value: 'YES' },
  117. { label: '拒绝', value: 'NO' }
  118. ]"
  119. :key="item.value"
  120. :label="item.value"
  121. >
  122. {{ item.label }}
  123. </el-radio>
  124. </el-radio-group>
  125. </div>
  126. <div class="mg">备注</div>
  127. <div>
  128. <el-input
  129. v-model="formData.remark"
  130. type="textarea"
  131. :rows="4"
  132. placeholder="请输入"
  133. :maxlength="-1"
  134. :show-word-limit="false"
  135. :autosize="{ minRows: 2, maxRows: 4 }"
  136. />
  137. </div>
  138. </div>
  139. <span slot="footer">
  140. <el-button @click="onClose">取消</el-button>
  141. <el-button type="primary" @click="onConfirm">确定</el-button>
  142. </span>
  143. </el-dialog>
  144. </template>
  145. <script>
  146. import { getDictList, getSalesmanList } from '@/api/common'
  147. import { replaceService, batchUpdate, applyUpdate, delOrder, examineUpdate, applyUpdateQuery } from '@/api/frock'
  148. export default {
  149. props: {
  150. operateVisible: {
  151. type: Boolean,
  152. default: false
  153. },
  154. operateType: {
  155. type: String,
  156. default: 'update'
  157. },
  158. operateTitle: {
  159. type: String,
  160. default: '更新'
  161. },
  162. recordSelected: {
  163. type: Array,
  164. default: () => []
  165. },
  166. detailId: {
  167. type: String,
  168. default: ''
  169. }
  170. },
  171. data() {
  172. return {
  173. show: false,
  174. visible: true,
  175. formData: {
  176. applyBy: '',
  177. applyCompany: '',
  178. applyReason: '',
  179. ids: [],
  180. isSuccess: 'YES',
  181. remark: '',
  182. serviceId: '',
  183. serviceName: '',
  184. status: 'ING'
  185. },
  186. tableData: [],
  187. currentPage: 1,
  188. listTotal: 0,
  189. followType: [],
  190. salesmanList: [],
  191. machineList: [],
  192. tableEvents: {
  193. 'selection-change': this.selectionChange
  194. },
  195. selectedData: []
  196. // operateConfig: ['update', 'delete', 'apply', 'replace', 'examine']
  197. }
  198. },
  199. computed: {
  200. columns() {
  201. return [
  202. {
  203. columnAttributes: {
  204. label: '工程编号',
  205. prop: 'projectNo',
  206. width: 150
  207. }
  208. },
  209. {
  210. columnAttributes: {
  211. label: '项目名称',
  212. prop: 'projectName',
  213. width: 200
  214. }
  215. },
  216. {
  217. columnAttributes: {
  218. label: '登录日期',
  219. prop: 'createTime',
  220. width: 150
  221. }
  222. },
  223. {
  224. columnAttributes: {
  225. label: '经销商名称',
  226. prop: 'customerName',
  227. width: 200
  228. }
  229. },
  230. {
  231. columnAttributes: {
  232. label: '业务员',
  233. prop: 'serviceName',
  234. width: 100
  235. }
  236. },
  237. {
  238. columnAttributes: {
  239. label: '机组类型',
  240. prop: 'machineType'
  241. }
  242. },
  243. {
  244. columnAttributes: {
  245. label: '工程地址',
  246. prop: 'address',
  247. width: 200
  248. }
  249. },
  250. {
  251. columnAttributes: {
  252. label: '跟进状态',
  253. prop: 'status'
  254. },
  255. render: (h, { row, column, $index }) => {
  256. const obj = {
  257. ING: '跟进中', LOSS: '已丢单', SIGN: '签订合同'
  258. }
  259. return (
  260. <div>
  261. {obj[row.status]}
  262. </div>
  263. )
  264. }
  265. }
  266. ]
  267. }
  268. },
  269. created() {
  270. this.visible = this.operateVisible
  271. this.tableData = this.recordSelected
  272. if (['update', 'replace'].includes(this.operateType)) {
  273. this.getDictList()
  274. this.operateType === 'replace' && this.getSalesmanList()
  275. }
  276. if (this.operateType === 'examine' && this.detailId) {
  277. this.getApplyUpdateQuery()
  278. }
  279. },
  280. methods: {
  281. getDictList() {
  282. getDictList({
  283. sysDictEnum: 'FOLLOW_STATUS'
  284. }).then(res => {
  285. this.followType = res.data.map(k => {
  286. return {
  287. label: k.dictValue,
  288. value: k.dictCode
  289. }
  290. })
  291. })
  292. },
  293. getSalesmanList() {
  294. getSalesmanList({
  295. pageNum: 1,
  296. pageSize: -1,
  297. isCustomer: 0,
  298. status: true
  299. }).then(res => {
  300. this.salesmanList = res.data.records.map(k => {
  301. return {
  302. label: k.nickName,
  303. value: k.adminUserId
  304. }
  305. })
  306. })
  307. },
  308. getApplyUpdateQuery() {
  309. applyUpdateQuery({ id: this.detailId }).then(res => {
  310. this.formData = {
  311. ...res.data
  312. }
  313. this.formData.isSuccess = 'YES'
  314. this.formData.status = 'ING'
  315. })
  316. },
  317. selectionChange(data) {
  318. this.selectedData = data
  319. },
  320. handleInterface(fn, tip) {
  321. fn.then(() => {
  322. this.$successMsg(tip)
  323. this.onClose()
  324. })
  325. },
  326. onConfirm() {
  327. let params
  328. const fnEnum = {
  329. update: () => {
  330. if (!this.formData.status) {
  331. this.$errorMsg('工单跟进状态不能为空')
  332. return
  333. }
  334. if (!this.selectedData.length) {
  335. this.$errorMsg('工程登录信息不能为空')
  336. return
  337. }
  338. const ids = this.selectedData.map(k => k.id)
  339. params = {
  340. status: this.formData.status,
  341. ids
  342. }
  343. this.handleInterface(batchUpdate(params), '更新成功')
  344. },
  345. replace: () => {
  346. if (!this.formData.serviceId) {
  347. this.$errorMsg('业务员不能为空')
  348. return
  349. }
  350. if (!this.selectedData.length) {
  351. this.$errorMsg('工程登录信息不能为空')
  352. return
  353. }
  354. const ids = this.selectedData.map(k => k.id)
  355. const serviceName = this.salesmanList.find(k => k.value === this.formData.serviceId).label
  356. params = {
  357. serviceId: this.formData.serviceId,
  358. serviceName,
  359. ids
  360. }
  361. this.handleInterface(replaceService(params), '替换成功')
  362. },
  363. apply: () => {
  364. if (!this.formData.remark) {
  365. this.$errorMsg('申请原因不能为空')
  366. return
  367. }
  368. params = {
  369. remark: this.formData.remark,
  370. ids: [this.detailId]
  371. }
  372. this.handleInterface(applyUpdate(params), '申请成功')
  373. },
  374. examine: () => {
  375. params = {
  376. remark: this.formData.remark,
  377. ids: [this.detailId]
  378. }
  379. this.handleInterface(examineUpdate)
  380. },
  381. delete: () => {
  382. const ids = this.tableData.map(k => k.id)
  383. this.handleInterface(delOrder(ids), '删除成功')
  384. }
  385. }
  386. fnEnum[this.operateType]()
  387. },
  388. onClose() {
  389. this.$emit('close')
  390. },
  391. handleSizeChange() {},
  392. handleCurrentChange() {}
  393. }
  394. }
  395. </script>
  396. <style lang="scss" scoped>
  397. .flex-box {
  398. display: flex;
  399. align-items: center;
  400. margin: 20px 0;
  401. &-title {
  402. flex: 0 0 100px;
  403. }
  404. }
  405. .mg {
  406. margin: 20px 0;
  407. }
  408. </style>