index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never" v-loading="loading">
  4. <plan-search class="seep-search" @search="reload"></plan-search>
  5. <!-- 数据表格 -->
  6. <ele-pro-table
  7. ref="table"
  8. :columns="columns"
  9. :datasource="datasource"
  10. cache-key="systemRoleTable"
  11. :pageSize="20"
  12. @cell-click="cellClick"
  13. >
  14. <!-- 表头工具栏 -->
  15. <template v-slot:toolbar>
  16. <el-button
  17. size="small"
  18. type="primary"
  19. @click="quotation"
  20. class="ele-btn-icon"
  21. >生成报价单</el-button
  22. >
  23. </template>
  24. <template v-slot:single="{ row }">
  25. <el-radio class="radio" v-model="radioId" :label="row.id">
  26. <i></i>
  27. </el-radio>
  28. </template>
  29. <template v-slot:code="{ row }">
  30. <el-link
  31. type="primary"
  32. :underline="false"
  33. @click="goDetail(row, 'view')"
  34. >{{ row.code }}</el-link
  35. >
  36. </template>
  37. <!-- 操作列 -->
  38. <template v-slot:action="{ row }">
  39. <el-link
  40. type="primary"
  41. :underline="false"
  42. @click="handleUpdate(row, 'edit')"
  43. v-if="
  44. [0, 4, 5].includes(row.planStatus) &&
  45. $hasPermission('eom:aftersalesplan:update')
  46. "
  47. >修改</el-link
  48. >
  49. <el-popconfirm
  50. class="ele-action"
  51. title="确认删除这条记录吗?"
  52. @confirm="cancel(row)"
  53. v-if="
  54. [0, 4, 5].includes(row.planStatus) &&
  55. $hasPermission('eom:aftersalesplan:delete')
  56. "
  57. >
  58. <template v-slot:reference>
  59. <el-link type="danger" :underline="false" icon="el-icon-delete"
  60. >删除</el-link
  61. >
  62. </template>
  63. </el-popconfirm>
  64. <el-link
  65. type="primary"
  66. :underline="false"
  67. @click="handleCommand('handleRevocation', row)"
  68. v-if="
  69. row.planStatus == 1 &&
  70. $hasPermission('eom:aftersalesplan:revocation')
  71. "
  72. >撤回</el-link
  73. >
  74. <el-link
  75. type="primary"
  76. :underline="false"
  77. @click="handleCommand('handleDispatchOrders', row)"
  78. v-if="
  79. [0, 4, 5].includes(row.planStatus) &&
  80. $hasPermission('eom:aftersalesplan:sendOrder')
  81. "
  82. >派单</el-link
  83. >
  84. </template>
  85. </ele-pro-table>
  86. </el-card>
  87. <addOrUpdateDialog
  88. ref="addOrUpdateDialogRef"
  89. @reload="reload"
  90. ></addOrUpdateDialog>
  91. <applyForSpare ref="edit" @reload="reload" />
  92. <generateForm ref="generateFormRef"></generateForm>
  93. <jimureportBrowse
  94. @cancelQuo="cancelQuo"
  95. v-if="browseShow"
  96. :browseShow="browseShow"
  97. :businessId="currentRow.id"
  98. businessCode="eomquotationprint"
  99. ></jimureportBrowse>
  100. </div>
  101. </template>
  102. <script>
  103. import planSearch from './components/plan-search.vue';
  104. import addOrUpdateDialog from './components/addOrUpdateDialog.vue';
  105. import generateForm from './components/generateForm.vue';
  106. import jimureportBrowse from '@/components/jimureport/browseModal.vue';
  107. import applyForSpare from '../components/applyForSpare.vue';
  108. import {
  109. getSalesPlan,
  110. deleteSalesPlan,
  111. planRevocation,
  112. checkByPlanId
  113. } from '@/api/salesServiceManagement/index';
  114. // import { getToken } from '@/utils/token-util';
  115. import dictMixins from '@/mixins/dictMixins';
  116. export default {
  117. mixins: [dictMixins],
  118. components: {
  119. planSearch,
  120. addOrUpdateDialog,
  121. generateForm,
  122. applyForSpare,
  123. jimureportBrowse
  124. },
  125. data() {
  126. return {
  127. // 表格列配置
  128. columns: [
  129. {
  130. columnKey: 'index',
  131. label: '序号',
  132. type: 'index',
  133. width: 55,
  134. align: 'center',
  135. showOverflowTooltip: true,
  136. fixed: 'left'
  137. },
  138. {
  139. action: 'single',
  140. slot: 'single',
  141. align: 'center',
  142. label: '选择',
  143. width: 50
  144. },
  145. {
  146. slot: 'code',
  147. prop: 'code',
  148. label: '计划单号',
  149. align: 'center',
  150. showOverflowTooltip: true
  151. },
  152. {
  153. prop: 'name',
  154. label: '计划名称',
  155. align: 'center',
  156. showOverflowTooltip: true
  157. },
  158. {
  159. prop: 'planExecuteUserName',
  160. label: '计划执行人',
  161. align: 'center',
  162. showOverflowTooltip: true
  163. },
  164. {
  165. prop: 'demandName',
  166. label: '需求名称',
  167. align: 'center',
  168. showOverflowTooltip: true
  169. },
  170. {
  171. prop: 'demandCode',
  172. label: '需求编码',
  173. align: 'center',
  174. showOverflowTooltip: true
  175. },
  176. {
  177. prop: 'categoryName',
  178. label: '设备名称',
  179. align: 'center',
  180. showOverflowTooltip: true,
  181. formatter: (row) => {
  182. if (!row.deviceDetails) return '';
  183. let str = '';
  184. row.deviceDetails.map((el, idx) => {
  185. if (idx + 1 == row.deviceDetails.length) {
  186. str += el.categoryName;
  187. } else {
  188. str = str + '' + el.categoryName + ',';
  189. }
  190. });
  191. return str;
  192. }
  193. },
  194. {
  195. prop: 'contactName',
  196. label: '客户名称',
  197. align: 'center',
  198. showOverflowTooltip: true
  199. },
  200. {
  201. prop: 'planStatus',
  202. label: '状态',
  203. align: 'center',
  204. showOverflowTooltip: true,
  205. formatter: (item) => {
  206. return {
  207. 0: '待派单',
  208. 1: '已派单',
  209. 2: '执行中',
  210. 3: '已完成',
  211. 4: '已撤回',
  212. 5: '已驳回'
  213. }[item.planStatus];
  214. }
  215. },
  216. {
  217. prop: 'urgent',
  218. label: '紧急程度',
  219. align: 'center',
  220. showOverflowTooltip: true,
  221. formatter: (item) => {
  222. return {
  223. 1: '普通',
  224. 2: '紧急',
  225. 3: '重要'
  226. }[item.urgent];
  227. }
  228. },
  229. {
  230. columnKey: 'action',
  231. label: '操作',
  232. width: 230,
  233. align: 'center',
  234. resizable: false,
  235. slot: 'action',
  236. showOverflowTooltip: true,
  237. fixed: 'right'
  238. }
  239. ],
  240. // 加载状态
  241. loading: false,
  242. radioId: '',
  243. currentRow: {},
  244. browseShow: false
  245. };
  246. },
  247. computed: {},
  248. created() {
  249. this.requestDict('维修计划状态');
  250. },
  251. methods: {
  252. /* 表格数据源 */
  253. datasource({ page, limit, where, order }) {
  254. return getSalesPlan({
  255. pageNum: page,
  256. size: limit,
  257. ...where
  258. });
  259. },
  260. /* 刷新表格 */
  261. reload(where) {
  262. this.$refs.table.reload({ page: 1, where });
  263. this.radioId = '';
  264. this.currentRow = {};
  265. this.$emit('getToDoReminder');
  266. },
  267. async cancel(row) {
  268. let flag = await this.permission(row);
  269. if (!flag) return;
  270. const res = await deleteSalesPlan([row.id]);
  271. if (res) {
  272. this.$message.success('删除成功');
  273. this.reload();
  274. }
  275. },
  276. async permission(row) {
  277. try {
  278. await checkByPlanId(row.id);
  279. return true;
  280. } catch {
  281. return false;
  282. }
  283. },
  284. async handleUpdate(row, type) {
  285. let flag = await this.permission(row);
  286. if (!flag) return;
  287. this.$nextTick(() => {
  288. this.$refs.addOrUpdateDialogRef.init(row, type);
  289. });
  290. },
  291. goDetail(row) {
  292. this.$nextTick(() => {
  293. this.$refs.addOrUpdateDialogRef.init(row, 'view');
  294. });
  295. },
  296. async handleDispatchOrders(row) {
  297. this.$nextTick(() => {
  298. this.$refs.addOrUpdateDialogRef.init(row, 'view', true);
  299. });
  300. },
  301. async handleRevocation(row) {
  302. await planRevocation([row.id]);
  303. this.$message.success('撤回成功');
  304. this.reload();
  305. },
  306. addSpareItems(row) {
  307. let data = JSON.parse(JSON.stringify(row));
  308. this.$refs.edit.open(data, 'plan');
  309. },
  310. async handleGenerate(row) {
  311. this.$refs.generateFormRef.open(row);
  312. },
  313. async handleCommand(command, row) {
  314. let flag = await this.permission(row);
  315. if (!flag) return;
  316. if (command === 'handleRevocation') {
  317. this.handleRevocation(row);
  318. }
  319. if (command === 'handleDispatchOrders') {
  320. this.handleDispatchOrders(row);
  321. }
  322. if (command === 'handleGenerate') {
  323. this.handleGenerate(row);
  324. }
  325. if (command === 'addSpareItems') {
  326. this.addSpareItems(row);
  327. }
  328. },
  329. // 单击选择
  330. cellClick(row) {
  331. this.currentRow = row;
  332. this.radioId = row.id;
  333. },
  334. quotation() {
  335. if (!this.currentRow.id) {
  336. this.$message.warning('请先选择计划');
  337. return;
  338. }
  339. this.browseShow = true;
  340. },
  341. cancelQuo() {
  342. this.browseShow = false;
  343. }
  344. }
  345. };
  346. </script>
  347. <style lang="scss" scoped>
  348. .el-dropdown-link {
  349. cursor: pointer;
  350. color: var(--color-primary-5);
  351. }
  352. .el-icon-arrow-down {
  353. font-size: 12px;
  354. }
  355. ::v-deep .seep-search {
  356. .el-input__inner {
  357. padding: 0 5px 0 10px;
  358. }
  359. .el-input__inner::placeholder {
  360. font-size: 13px;
  361. }
  362. }
  363. </style>