form.vue 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762
  1. <template>
  2. <!-- 添加或修改项目信息对话框 -->
  3. <div class="el-drawer__wrapper">
  4. <el-drawer :title="title" v-model="visible" direction="rtl" size="100%">
  5. <div class="page-container form-container">
  6. <div class="form-btns-container">
  7. <span class="title-label"><el-icon>
  8. <Document />
  9. </el-icon>
  10. 合同信息</span>
  11. <el-button v-if="form.verifyStatus == 0 && !editStatus" type="warning" size="small" icon="Edit"
  12. @click="editStatus = true">修改</el-button>
  13. <el-button v-if="form.id && editStatus" type="info" size="small" icon="Close" @click="
  14. () => {
  15. editStatus = false;
  16. getForm();
  17. }
  18. ">取消修改</el-button>
  19. <el-button v-if="form.id" type="success" size="small" icon="refresh" @click="getForm">
  20. 刷新
  21. </el-button>
  22. <el-button v-show="form.id && !editStatus && form.verifyStatus == 0"
  23. v-hasPermi="['business:archive:order:verify']" type="primary" size="small" icon="check"
  24. @click="verifyHandler">审核通过</el-button>
  25. <el-button v-show="form.id && !editStatus && form.verifyStatus == 0"
  26. v-hasPermi="['business:archive:order:verify']" type="danger" size="small" icon="back"
  27. @click="rejectHandler">驳回</el-button>
  28. <el-button v-show="form.alterNumber > 0 && !editStatus" v-hasPermi="['business:archive:order:history']"
  29. type="info" size="small" icon="Notebook" @click="showHistoryList">历史记录</el-button>
  30. <div class="screen-btn" @click="handleScreen">
  31. <template v-if="!isFullscreen">
  32. <i class="fa fa-window-maximize" aria-hidden="true" />
  33. <!-- <span>全屏</span> -->
  34. </template>
  35. <template v-else>
  36. <i class="fa fa-window-restore" aria-hidden="true" />
  37. <!-- <span>还原</span> -->
  38. </template>
  39. </div>
  40. <div class="close-btn" @click="cancel">
  41. <i class="fa fa-times" aria-hidden="true" />
  42. <!-- <span>关闭</span> -->
  43. </div>
  44. </div>
  45. <div class="Y-scrollbar" style="
  46. position: absolute;
  47. top: 32px;
  48. bottom: 0;
  49. width: 100%;
  50. overflow: auto;
  51. "></div>
  52. <el-form ref="orderRef" class="master-container" size="small" :model="form" :rules="rules" label-width="100px">
  53. <el-row :gutter="30">
  54. <el-col :span="6">
  55. <el-form-item label="合同编号" prop="contractNo">
  56. <el-input v-if="editStatus && type !== 'alterOrder'" v-model="form.contractNo" placeholder="请输入合同编号"
  57. width="100px" />
  58. <span v-else>{{ form.contractNo }}</span>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="6">
  62. <el-form-item label="合同类型" prop="contractType">
  63. <el-radio-group v-if="editStatus || type == 'alterOrder'" v-model="form.contractType"
  64. @change="contractTypeChangeHandler">
  65. <el-radio :label="0">新签</el-radio>
  66. <el-radio :label="1">续签</el-radio>
  67. </el-radio-group>
  68. <span v-else>{{
  69. form.contractType === 0 ? "新签" : "续签"
  70. }}</span>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="6">
  74. <el-form-item label="客户名称" prop="companyId">
  75. <template v-if="editStatus && type !== 'alterOrder'">
  76. <el-autocomplete :fetch-suggestions="querySearchCompanyAsync" :trigger-on-focus="true"
  77. v-model="form.companyName" placeholder="请输入客户名称" popper-class="my-autocomplete" clearable
  78. @clear="handleClearCompany" @select="handleSelectCompany" style="width: 100%">
  79. <template #append>
  80. <el-button icon="Plus" @click="showAddCompanyDialog">
  81. </el-button>
  82. </template>
  83. <template #default="{ item }">
  84. <div style="
  85. display: flex;
  86. flex-direction: row;
  87. justify-content: space-between;
  88. ">
  89. <div class="name" style="font-size: 12px">
  90. {{ item.name }}
  91. </div>
  92. </div>
  93. </template>
  94. </el-autocomplete>
  95. <!-- <el-button @click="showAddCompanyDialog">
  96. <el-icon class="el-input__icon">
  97. <plus />
  98. </el-icon>
  99. </el-button> -->
  100. </template>
  101. <el-link :underline="false" type="primary" @click="handleInfo(form)" v-else>{{ form.companyName
  102. }}</el-link>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="6">
  106. <el-form-item label="签约日期" prop="formDate">
  107. <el-date-picker v-if="editStatus && type !== 'alterOrder'" clearable v-model="form.formDate" type="date"
  108. value-format="YYYY-MM-DD" placeholder="请选择签约日期">
  109. </el-date-picker>
  110. <span v-else>{{ form.formDate }}</span>
  111. </el-form-item>
  112. </el-col>
  113. <el-col :span="6">
  114. <el-form-item label="签单人" prop="signerName">
  115. <el-autocomplete v-if="editStatus && type !== 'alterOrder'" :fetch-suggestions="querySearchAsync"
  116. :trigger-on-focus="true" style="width: 100%" v-model="form.signerName" placeholder="请输入签单人"
  117. popper-class="my-autocomplete" @select="handleSelectEmployee">
  118. <template #default="{ item }">
  119. <div style="
  120. display: flex;
  121. flex-direction: row;
  122. justify-content: space-between;
  123. ">
  124. <div class="name" style="font-size: 12px">
  125. {{ item.nickName }}
  126. </div>
  127. <span class="code" style="font-size: 10px; color: darkgrey">{{ item.userName }}</span>
  128. </div>
  129. </template>
  130. </el-autocomplete>
  131. <span v-else>{{ form.signerName }}</span>
  132. </el-form-item>
  133. </el-col>
  134. <el-col v-if="form.verifyStatus === 4" :span="6">
  135. <el-form-item label="驳回原因" prop="verifyRemark">
  136. <span>{{ form.verifyRemark }}</span>
  137. </el-form-item>
  138. </el-col>
  139. <el-col :span="6" style="width: 100%">
  140. <el-form-item label="来源" prop="sourceCategoryName" style="width: 100%">
  141. <CustomerFormCom ref="CustomerFormComRef" :edit-status="editStatus && type !== 'alterOrder'"
  142. :form-data="form" :source-categories="sourceCategories" />
  143. </el-form-item>
  144. </el-col>
  145. <el-col :span="6">
  146. <el-form-item label-width="100px" label="客户标签" prop="customerLabelId">
  147. <span>{{ selectedOptionLabel }}</span>
  148. </el-form-item>
  149. </el-col>
  150. <el-col :span="6">
  151. <el-form-item label="甲方" prop="boss">
  152. <el-input v-if="editStatus" v-model="form.boss" style="width: 100%; margin: 0; padding: 0"
  153. placeholder="请输入甲方名称" />
  154. <span v-else>{{ form.boss }}</span>
  155. </el-form-item>
  156. </el-col>
  157. <el-col :span="6">
  158. <el-form-item label="乙方" prop="party">
  159. <el-input v-if="editStatus" v-model="form.party" style="width: 100%; margin: 0; padding: 0"
  160. placeholder="请输入乙方名称" />
  161. <span v-else>{{ form.party }}</span>
  162. </el-form-item>
  163. </el-col>
  164. <el-col :span="6">
  165. <el-form-item style="display: flex;flex-wrap: nowrap;" label="客户历史使用名" prop="oldName">
  166. <el-tooltip
  167. class="box-item"
  168. effect="dark"
  169. content=""
  170. placement="top"
  171. >
  172. <template #content>{{form.oldName}}</template>
  173. <span :show-overflow-tooltip="true" style="white-space: nowrap; /* 防止换行 */ overflow: hidden; /* 如果内容宽度超过span定义的宽度,则隐藏超出部分 */
  174. text-overflow: ellipsis; /* 可选,如果想要超出部分显示为省略号 */">{{ form.oldName}}</span>
  175. </el-tooltip>
  176. </el-form-item>
  177. </el-col>
  178. <el-col :span="6">
  179. <el-form-item v-if="!editStatus" label="合同状态" prop="status">
  180. <dict-tag :options="contract_status" :value="form.status" />
  181. </el-form-item>
  182. </el-col>
  183. <el-col :span="6">
  184. <el-form-item v-if="!editStatus && form.dissolution === 1" label="解除时间" prop="dissolution">
  185. <span >{{ form.dissDate }}</span>
  186. </el-form-item>
  187. </el-col>
  188. <el-col :span="20">
  189. <el-form-item label="备注" prop="remark">
  190. <el-input v-if="editStatus" v-model="form.remark" show-word-limit maxlength="250"
  191. style="width: 100%; margin: 0; padding: 0" placeholder="请输入备注" type="textarea" :rows="4" />
  192. <span v-else>{{ form.remark }}</span>
  193. </el-form-item>
  194. </el-col>
  195. <br />
  196. <el-col :span="24">
  197. <el-tabs v-model="form.serviceType" size="small" class="demo-tabs" @tab-change="handleServiceTypeClick">
  198. <el-tab-pane :disabled="!editStatus" label="循环服务" :name="1">
  199. <el-row>
  200. <el-col :span="24">
  201. <el-checkbox-group v-model="loops" @change="(arg) => changeDetails('loop', arg)">
  202. <el-checkbox v-for="(item, index) in loopTasks" :key="index" :label="item.id"
  203. :disabled="item.isDisabled || !editStatus">{{ item.name }}</el-checkbox>
  204. </el-checkbox-group>
  205. </el-col>
  206. <el-col :span="24">
  207. <el-row v-for="(item, index) in loopDetails" :key="index" style="
  208. border-radius: 5px;
  209. border-color: rgba(0, 0, 0, 20%);
  210. border-style: solid;
  211. border-width: 1px;
  212. margin-bottom: 10px;
  213. ">
  214. <el-col :span="4" style="padding-top: 18px">
  215. <el-form-item label="服务项目">
  216. {{ item.taskTypeName }}
  217. </el-form-item>
  218. </el-col>
  219. <el-col :span="4" style="padding-top: 18px">
  220. <el-form-item label="月单价">
  221. <el-input-number v-if="editStatus" v-model="item.price" :precision="2" :step="0.1" :min="0"
  222. :controls="false" @change="
  223. (arg) =>
  224. inputChangeHandler('loop', 'price', item, arg)
  225. " />
  226. <div v-else>{{ rowNum(item.price) }}</div>
  227. </el-form-item>
  228. </el-col>
  229. <el-col :span="4" style="padding-top: 18px">
  230. <el-form-item label="服务月数">
  231. <el-input-number v-if="editStatus" v-model="item.serviceNum" :step="1" step-strictly
  232. :min="0" :disabled="item.monthDisabled" :controls="false" @change="
  233. (arg) =>
  234. inputChangeHandler(
  235. 'loop',
  236. 'serviceNum',
  237. item,
  238. arg
  239. )
  240. " />
  241. <div v-else>{{ item.serviceNum }}</div>
  242. </el-form-item>
  243. </el-col>
  244. <el-col :span="4" style="padding-top: 18px">
  245. <el-form-item label="赠送月数">
  246. <el-input-number v-if="editStatus" v-model="item.freeNum" :step="1" step-strictly :min="0"
  247. :disabled="item.monthDisabled" :controls="false" @change="
  248. (arg) =>
  249. inputChangeHandler(
  250. 'loop',
  251. 'freeNum',
  252. item,
  253. arg
  254. )
  255. " />
  256. <div v-else>{{ item.freeNum }}</div>
  257. </el-form-item>
  258. </el-col>
  259. <el-col :span="4" style="padding-top: 18px">
  260. <el-form-item label="优惠金额">
  261. <el-input-number v-if="editStatus" v-model="item.discountAmount" :precision="2" :step="0.1"
  262. :min="0" :controls="false" @change="
  263. (arg) =>
  264. inputChangeHandler('loop', 'discountAmount', item, arg)
  265. " />
  266. <div v-else>{{ rowNum(item.discountAmount) }}</div>
  267. </el-form-item>
  268. </el-col>
  269. <el-col :span="4" style="padding-top: 18px">
  270. <el-form-item label="合计金额">
  271. <div>{{ rowNum(item.amount) }}</div>
  272. </el-form-item>
  273. </el-col>
  274. <el-col :span="4" style="padding-top: 18px">
  275. <el-form-item label="服务区间"
  276. v-if="item.timeVo != null && item.timeVo != undefined && type !== 'alterOrder'">
  277. <div>{{timeVoFormat(item.timeVo)}}</div>
  278. </el-form-item>
  279. </el-col>
  280. <el-col :span="4" style="padding-top: 18px" v-if="item.taskTypeId ==4">
  281. </el-col>
  282. <el-col :span="4" style="padding-top: 18px" v-if="item.taskTypeId ==4">
  283. <el-form-item label="所属区">
  284. <el-select v-if="editStatus" v-model="item.belongRegion" style="margin-right: 5px">
  285. <el-option v-for="region in belong_region" :key="region.value" :label="region.label"
  286. :value="region.id"></el-option>
  287. </el-select>
  288. <span v-else>{{item.regionName}}</span>
  289. </el-form-item>
  290. </el-col>
  291. </el-row>
  292. </el-col>
  293. <el-divider />
  294. </el-row>
  295. </el-tab-pane>
  296. <el-tab-pane :disabled="!editStatus " label="代办服务" :name="2">
  297. <el-checkbox-group :disabled="!editStatus" v-model="onces"
  298. @change="(arg) => changeDetails('once', arg)">
  299. <el-checkbox v-for="(item, index) in onceTasks" :key="index" :label="item.id">{{ item.name
  300. }}</el-checkbox>
  301. </el-checkbox-group>
  302. <el-col :span="24">
  303. <el-row v-for="(item, index) in onceDetails" :key="index" style="
  304. border-radius: 5px;
  305. border-color: rgba(0, 0, 0, 20%);
  306. border-style: solid;
  307. border-width: 1px;
  308. margin-bottom: 10px;
  309. ">
  310. <el-col :span="4" style="padding-top: 18px">
  311. <el-form-item label="服务项目">
  312. {{ item.taskTypeName }}
  313. </el-form-item>
  314. </el-col>
  315. <el-col v-if="item.payAddress === 1" :span="9" style="
  316. padding-top: 18px;
  317. padding-left: 35px;
  318. display: flex;
  319. flex-direction: column;
  320. margin-bottom: 18px;
  321. ">
  322. <el-radio-group v-if="editStatus" v-model="item.addressStyle" @change="changeProcesses(item)">
  323. <el-radio :label="1" style="margin-bottom: 5px">
  324. <template #default>
  325. <div style="
  326. display: flex;
  327. flex-direction: row;
  328. width: 300px;
  329. justify-content: space-between;
  330. ">
  331. <div style="
  332. display: inline-block;
  333. height: 24px;
  334. line-height: 24px;
  335. margin-right: 10px;
  336. ">
  337. 自有地址
  338. </div>
  339. <div>
  340. <el-select :disabled="item.addressStyle === 2" v-model="item.provinceCode"
  341. placeholder="省份" style="width: 36%" @change="handleSelectProvince(item, index)">
  342. <el-option v-for="item in provincesArr[index]" :key="item.code" :label="item.name"
  343. :value="item.code" />
  344. </el-select>
  345. <el-select :disabled="item.addressStyle === 2" v-model="item.cityCode"
  346. placeholder="城市" style="width: 37%" @change="handleSelectCity(item, index)">
  347. <el-option v-for="item in citiesArr[index]" :key="item.code" :label="item.name"
  348. :value="item.code" />
  349. </el-select>
  350. <el-select :disabled="item.addressStyle === 2" v-model="item.districtCode"
  351. placeholder="行政区" style="width: 37%" @change="handleSelectDistrict(item, index)">
  352. <el-option v-for="item in districtsArr[index]" :key="item.code" :label="item.name"
  353. :value="item.code" />
  354. </el-select>
  355. </div>
  356. </div>
  357. </template>
  358. </el-radio>
  359. <el-radio :label="2" style="margin-bottom: 5px">
  360. <template #default>
  361. <div style="
  362. display: flex;
  363. flex-direction: row;
  364. width: 325px;
  365. justify-content: space-between;
  366. ">
  367. <div style="
  368. display: inline-block;
  369. height: 24px;
  370. line-height: 24px;
  371. margin-right: 10px;
  372. ">
  373. 虚拟地址
  374. </div>
  375. <el-select :disabled="item.addressStyle !== 2" v-model="item.fictionAddressId"
  376. style="margin-right: 5px">
  377. <el-option v-for="item in virtual_address" :key="item.value" :label="item.label"
  378. :value="item.id"></el-option>
  379. </el-select>
  380. <div style="
  381. display: inline-block;
  382. height: 24px;
  383. line-height: 24px;
  384. ">
  385. 金额:
  386. </div>
  387. <el-input-number :disabled="item.addressStyle !== 2" v-if="editStatus"
  388. v-model="item.addressAmount" :precision="2" :step="0.01" step-strictly
  389. :controls="false" @change="
  390. (arg) =>
  391. inputChangeHandler(
  392. 'once',
  393. 'addressAmount',
  394. item,
  395. arg
  396. )
  397. " />
  398. </div>
  399. </template>
  400. </el-radio>
  401. </el-radio-group>
  402. <div v-else style="
  403. display: flex;
  404. flex-direction: row;
  405. width: 300px;
  406. justify-content: space-between;
  407. font-size: 12px;
  408. ">
  409. <div>
  410. {{
  411. item.addressStyle === 1
  412. ? "自有地址"
  413. : item.addressStyle === 2
  414. ? "虚拟地址"
  415. : ""
  416. }}
  417. </div>
  418. <div v-if="item.addressStyle === 1">
  419. 注册地区:{{ item.province }} - {{ item.city }} -
  420. {{ item.district }}
  421. </div>
  422. <div v-if="item.addressStyle === 2">
  423. {{ (item.fictionAddress) }}
  424. </div>
  425. <div v-if="item.addressStyle === 2">
  426. 金额:{{ rowNum(item.addressAmount) }}
  427. </div>
  428. </div>
  429. </el-col>
  430. <el-col v-if="item.payAddress === 0" :span="9" style="
  431. padding-top: 18px;
  432. display: flex;
  433. flex-direction: column;
  434. margin-bottom: 18px;
  435. ">
  436. <el-form-item v-if="item.taskTypeId === '6'" label="变更类型">
  437. <el-select v-if="editStatus" v-model="item.alterType" style="width: 280px">
  438. <el-option v-for="alter in alterTypes" :label="alter.label" :key="alter.value"
  439. :value="alter.value">
  440. </el-option>
  441. </el-select>
  442. <div v-else>{{ item.alterType }}</div>
  443. </el-form-item>
  444. <div v-if="item.alterType === '跨区变更'" style="margin-left: 60px">
  445. <el-radio-group v-if="editStatus" v-model="item.addressStyle" @change="changeProcesses(item)">
  446. <el-radio :label="1" style="margin-bottom: 5px">
  447. <template #default>
  448. <div style="
  449. display: flex;
  450. flex-direction: row;
  451. width: 300px;
  452. justify-content: space-between;
  453. ">
  454. <div style="
  455. display: inline-block;
  456. height: 24px;
  457. line-height: 24px;
  458. margin-right: 10px;
  459. ">
  460. 自有地址
  461. </div>
  462. <div>
  463. <el-select :disabled="item.addressStyle === 2" v-model="item.provinceCode"
  464. placeholder="省份" style="width: 33.33%" @change="
  465. handleSelectProvince(item, index)
  466. ">
  467. <el-option v-for="item in provincesArr[index]" :key="item.code" :label="item.name"
  468. :value="item.code" />
  469. </el-select>
  470. <el-select :disabled="item.addressStyle === 2" v-model="item.cityCode"
  471. placeholder="城市" style="width: 33.33%" @change="handleSelectCity(item, index)">
  472. <el-option v-for="item in citiesArr[index]" :key="item.code" :label="item.name"
  473. :value="item.code" />
  474. </el-select>
  475. <el-select :disabled="item.addressStyle === 2" v-model="item.districtCode"
  476. placeholder="行政区" style="width: 33.33%" @change="
  477. handleSelectDistrict(item, index)
  478. ">
  479. <el-option v-for="item in districtsArr[index]" :key="item.code" :label="item.name"
  480. :value="item.code" />
  481. </el-select>
  482. </div>
  483. </div>
  484. </template>
  485. </el-radio>
  486. <el-radio :label="2" style="margin-bottom: 5px">
  487. <template #default>
  488. <div style="
  489. display: flex;
  490. flex-direction: row;
  491. width: 300px;
  492. justify-content: space-between;
  493. ">
  494. <div style="
  495. display: inline-block;
  496. height: 24px;
  497. line-height: 24px;
  498. margin-right: 10px;
  499. ">
  500. 虚拟地址
  501. </div>
  502. <el-select :disabled="item.addressStyle !== 2" v-model="item.fictionAddressId"
  503. style="margin-right: 5px">
  504. <el-option v-for="item in virtual_address" :key="item.value" :label="item.label"
  505. :value="item.id"></el-option>
  506. </el-select>
  507. <div style="
  508. display: inline-block;
  509. height: 24px;
  510. line-height: 24px;
  511. ">
  512. 金额:
  513. </div>
  514. <el-input-number :disabled="item.addressStyle !== 2" v-if="editStatus"
  515. v-model="item.addressAmount" :precision="2" :step="0.01" step-strictly
  516. :controls="false" @change="
  517. (arg) =>
  518. inputChangeHandler(
  519. 'once',
  520. 'addressAmount',
  521. item,
  522. arg
  523. )
  524. " />
  525. </div>
  526. </template>
  527. </el-radio>
  528. </el-radio-group>
  529. <div v-else style="
  530. display: flex;
  531. flex-direction: row;
  532. width: 300px;
  533. justify-content: space-between;
  534. font-size: 12px;
  535. ">
  536. <div>
  537. {{
  538. item.addressStyle === 1
  539. ? "自有地址"
  540. : item.addressStyle === 2
  541. ? "虚拟地址"
  542. : ""
  543. }}
  544. </div>
  545. <div v-if="item.addressStyle === 1">
  546. 注册地区:{{ item.province }} - {{ item.city }} -
  547. {{ item.district }}
  548. </div>
  549. <div v-if="item.addressStyle === 2">
  550. {{ item.fictionAddress }}
  551. </div>
  552. <div v-if="item.addressStyle === 2">
  553. 金额:{{ rowNum(item.addressAmount) }}
  554. </div>
  555. </div>
  556. </div>
  557. <el-form-item v-else label="办理地区">
  558. <div v-if="editStatus" style="
  559. display: flex;
  560. flex-direction: row;
  561. width: 280px;
  562. justify-content: space-between;
  563. ">
  564. <el-select v-model="item.provinceCode" placeholder="省份" style="width: 33.33%"
  565. @click.stop="null" @change="handleSelectProvince(item, index)">
  566. <el-option v-for="item in provincesArr[index]" :key="item.code" :label="item.name"
  567. :value="item.code" />
  568. </el-select>
  569. <el-select v-model="item.cityCode" placeholder="城市" style="width: 33.33%"
  570. @change="handleSelectCity(item, index)" @click.stop="null">
  571. <el-option v-for="item in citiesArr[index]" :key="item.code" :label="item.name"
  572. :value="item.code" />
  573. </el-select>
  574. <el-select v-model="item.districtCode" placeholder="行政区" style="width: 33.33%"
  575. @change="handleSelectDistrict(item, index)" @click.stop="null">
  576. <el-option v-for="item in districtsArr[index]" :key="item.code" :label="item.name"
  577. :value="item.code" />
  578. </el-select>
  579. </div>
  580. <div v-else style="
  581. display: flex;
  582. flex-direction: row;
  583. width: 300px;
  584. justify-content: space-between;
  585. ">
  586. {{ item.province }} - {{ item.city }} -
  587. {{ item.district }}
  588. </div>
  589. </el-form-item>
  590. </el-col>
  591. <el-col :span="7" style="padding-top: 18px; margin-bottom: 18px">
  592. <el-checkbox-group :disabled="!editStatus" v-model="item.processes"
  593. @change="(arg) => changeProcesses(item, arg)" style="display: flex; flex-direction: column">
  594. <el-checkbox v-for="(process, index) in item.defaultProcesses" :key="index" :label="process">
  595. <template #default>
  596. <div style="
  597. display: flex;
  598. flex-direction: row;
  599. width: 300px;
  600. justify-content: space-between;
  601. ">
  602. <div style="
  603. display: inline-block;
  604. height: 24px;
  605. line-height: 24px;
  606. margin-right: 10px;
  607. width: 80px;
  608. ">
  609. {{ process.taskTypeDetailName }}
  610. </div>
  611. <div style="
  612. display: inline-block;
  613. height: 24px;
  614. line-height: 24px;
  615. ">
  616. 金额:
  617. </div>
  618. <el-input-number :disabled="
  619. checkedProcess(
  620. process.taskTypeDetailId,
  621. item
  622. )
  623. " size="small" v-if="editStatus" v-model="process.amount" :precision="2" :step="0.01"
  624. step-strictly :controls="false" style="width: 100px" @click.stop="null" @change="
  625. (arg) =>
  626. inputChangeHandler(
  627. 'process',
  628. 'amount',
  629. process,
  630. arg,
  631. item
  632. )
  633. " />
  634. <div v-else style="
  635. display: inline-block;
  636. height: 24px;
  637. line-height: 24px;
  638. width: 40px;
  639. text-align: right;
  640. ">
  641. {{ rowNum(process.amount) }}
  642. </div>
  643. </div>
  644. </template>
  645. <!-- {{ process.name }} -->
  646. </el-checkbox>
  647. </el-checkbox-group>
  648. </el-col>
  649. <el-col :span="3" style="
  650. padding-top: 18px;
  651. display: flex;
  652. flex-direction: column;
  653. margin-bottom: 18px;
  654. ">
  655. <div style="
  656. display: flex;
  657. flex-direction: row;
  658. font-size: 12px;
  659. ">
  660. <div style="
  661. display: inline-block;
  662. height: 24px;
  663. line-height: 24px;
  664. margin-left: 10px;
  665. ">
  666. 总金额:
  667. </div>
  668. <div style="
  669. display: inline-block;
  670. height: 24px;
  671. line-height: 24px;
  672. ">
  673. {{ rowNum(item.amount) }}
  674. </div>
  675. </div>
  676. </el-col>
  677. <el-col :span="4" style="padding-top: 18px">
  678. </el-col>
  679. <el-col v-if="item.taskTypeId == 9 || item.taskTypeId == 8" :span="9" style="
  680. padding-top: 18px;
  681. display: flex;
  682. flex-direction: column;
  683. margin-bottom: 18px;
  684. ">
  685. <el-form-item label="备注" prop="remark">
  686. <el-input v-model="item.remark" v-if="editStatus" />
  687. <div v-else>{{ item.remark }}</div>
  688. </el-form-item>
  689. </el-col>
  690. </el-row>
  691. </el-col>
  692. <el-divider />
  693. </el-tab-pane>
  694. </el-tabs>
  695. </el-col>
  696. <el-col :span="6">
  697. <el-form-item label="合计:" prop="remark">
  698. <span>{{ rowNum(form.amount) }}</span>
  699. </el-form-item>
  700. </el-col>
  701. <el-col :span="6">
  702. <el-form-item label="优惠金额:">
  703. <span>{{ rowNum(form.discountAmount) }}</span>
  704. </el-form-item>
  705. </el-col>
  706. <el-col :span="6">
  707. <el-form-item label="实收:">
  708. <div>{{ rowNum(form.trueAmount) }}</div>
  709. </el-form-item>
  710. </el-col>
  711. <br />
  712. <el-col :span="24">
  713. <div class="details-head" style="font-size: 12px">
  714. <div class="title">
  715. <i class="fa fa-th-list" aria-hidden="true" /> 合同附件
  716. </div>
  717. <div class="details-btns-container" style="display: flex">
  718. <el-upload v-if="editStatus" action="#" :http-request="upload"
  719. :with-credentials="true" :show-file-list="false" multiple>
  720. <el-button style="margin-top: 10px; margin-bottom:10px;" size="small" type="primary"
  721. icon="Upload">点击上传</el-button>
  722. </el-upload>
  723. </div>
  724. </div>
  725. <div class="details-body" style="height: 200px">
  726. <el-table ref="filesTable" :data="form.files" size="small" height="100%" border
  727. header-row-class-name="list-header-row">
  728. <el-table-column type="index" label="序号" width="47" align="center" />
  729. <el-table-column label="文件名" prop="originalFileName" align="center">
  730. <template #default="scope">
  731. <el-link :href="`${baseUrl}${scope.row.fileUrl}`" :underline="false" target="_blank"
  732. type="primary">
  733. {{ scope.row.originalFileName }}
  734. </el-link>
  735. </template>
  736. </el-table-column>
  737. <el-table-column v-if="editStatus && type !== 'alterOrder'" label="操作" width="70" align="center">
  738. <template #default="scope">
  739. <el-button link size="small" type="danger" @click="handleDelFile(scope.$index)">删除</el-button>
  740. </template>
  741. </el-table-column>
  742. </el-table>
  743. </div>
  744. <br />
  745. </el-col>
  746. <el-col v-if="editStatus" :span="24" style="
  747. text-align: center;
  748. display: flex;
  749. flex-direction: row;
  750. justify-content: center;
  751. ">
  752. <el-button size="small" type="primary" icon="Finished" style="width: 160px"
  753. @click="submitForm">保存</el-button>
  754. </el-col>
  755. </el-row>
  756. <br />
  757. </el-form>
  758. </div>
  759. </el-drawer>
  760. <el-dialog title="驳回详情" v-model="rejectOpen" width="500px" append-to-body draggable :close-on-click-modal="false">
  761. <el-form ref="dictRef" :model="form" label-width="100">
  762. <el-form-item label="驳回原因" :prop="verifyRemark">
  763. <el-input v-model.trim="form.verifyRemark" type="textarea" :rows="3" placeholder="请输入驳回原因" maxlength="200"
  764. show-word-limit />
  765. </el-form-item>
  766. </el-form>
  767. <template #footer>
  768. <div class="dialog-footer">
  769. <el-button type="primary" icon="Finished" size="small" @click="verifyUpload(4)">确 定</el-button>
  770. <el-button icon="close" size="small" @click="rejectCancel">取 消</el-button>
  771. </div>
  772. </template>
  773. </el-dialog>
  774. <el-dialog title="是否续签" v-model="verifyOpen" width="600px" append-to-body draggable>
  775. <el-form ref="dictRef" :model="verifyForm" label-width="380" size="small">
  776. <el-form-item v-for="item in redirectDetails" :key="item.id"
  777. :label="`${item.taskTypeName}上个任务结束月:${item.endMonth}是否重新开始`">
  778. <el-checkbox v-model="item.redirect" />
  779. </el-form-item>
  780. </el-form>
  781. <template #footer>
  782. <div class="dialog-footer">
  783. <el-button type="primary" icon="Finished" size="small" @click="redirectVerify()">确 定</el-button>
  784. <el-button icon="close" size="small" @click="verifyFormClose">取 消</el-button>
  785. </div>
  786. </template>
  787. </el-dialog>
  788. <AddCompanyDialog ref="addCompanyDialogRef" />
  789. <company-form ref="companyRef" :get-list="getList"></company-form>
  790. <dialog-history-choice ref="historyChoiceRef" @choice="historyChoiceHandle" />
  791. </div>
  792. </template>
  793. <script setup>
  794. import { uploadFile } from "@/api/tool/file";
  795. import { listLableNoPage } from "@/api/business/lable";
  796. import AddCompanyDialog from "../AddCompanyDialog";
  797. import match from "@/utils/match";
  798. import {
  799. getOrder,
  800. initTaskTypes,
  801. addOrder,
  802. updateOrder,
  803. verifyOrder,
  804. alterOrder,
  805. dissolutionOrder,
  806. verifyCheckOrder,
  807. } from "@/api/business/crm/contract";
  808. import { listSource } from "@/api/settings/source";
  809. import { listCompany } from "@/api/business/crm/company";
  810. import { listUser } from "@/api/system/user";
  811. import CustomerFormCom from "@/components/CustomerFormCom";
  812. import DialogHistoryChoice from "@/views/dialog/DialogHistoryChoice.vue";
  813. import { formatDate, rowNum } from "@/utils/index";
  814. import { ref } from "vue";
  815. import companyForm from "@/views/business/crm/company/formView.vue";
  816. import useUserStore from "@/store/modules/user";
  817. // import { it } from "element-plus/es/locale";
  818. const { proxy } = getCurrentInstance();
  819. const verifyOpen = ref(false);
  820. const verifyForm = ref({});
  821. const redirectDetails = ref([]);
  822. const baseUrl = import.meta.env.VITE_APP_BASE_API;
  823. const historyChoiceRef = ref(null);
  824. const alterTypes = ref([
  825. {
  826. value: "普通变更",
  827. label: "普通变更",
  828. },
  829. {
  830. value: "股权变更",
  831. label: "股权变更",
  832. },
  833. {
  834. value: "减资",
  835. label: "减资",
  836. },
  837. {
  838. value: "跨区变更",
  839. label: "跨区变更",
  840. },
  841. ]);
  842. /** 父组件传参 */
  843. const props = defineProps({
  844. getList: {
  845. type: Function,
  846. default: () => { },
  847. },
  848. });
  849. const { getList } = toRefs(props);
  850. /** 字典数组区 */
  851. const { virtual_address } = proxy.useDict("virtual_address");
  852. const { belong_region } = proxy.useDict("belong_region");
  853. const { contract_status } = proxy.useDict("contract_status");
  854. /** 表单抽屉 页变量 */
  855. const title = ref("");
  856. const loading = ref(false);
  857. const multiple = ref(true);
  858. const visible = ref(false);
  859. const editStatus = ref(false);
  860. const loopTasks = ref([]);
  861. const onceTasks = ref([]);
  862. const sourceCategories = ref([]);
  863. const loops = ref([]);
  864. const onces = ref([]);
  865. const type = ref("");
  866. const addCompanyDialogRef = ref(null);
  867. const rejectOpen = ref(false);
  868. // 循环任务明细
  869. const loopDetails = ref([]);
  870. // 单次任务明细
  871. const onceDetails = ref([]);
  872. const detailEmpty = {
  873. id: null,
  874. taskTypeName: "",
  875. taskTypeId: null,
  876. serviceNum: undefined,
  877. freeNum: undefined,
  878. price: undefined,
  879. amount: undefined,
  880. addressStyle: undefined,
  881. address: undefined,
  882. fictionAddressId: undefined,
  883. tenantId: undefined,
  884. province: "",
  885. city: "",
  886. district: "",
  887. addressStyle: 1,
  888. provinceId: undefined,
  889. processes: [],
  890. defaultProcesses: [],
  891. };
  892. //地址数组
  893. const provincesArr = ref([]);
  894. const citiesArr = ref([]);
  895. const districtsArr = ref([]);
  896. const provinces = ref(proxy.region.getProvinces());
  897. provinces.value.unshift({ code: "", name: "全部" });
  898. const cities = ref([]);
  899. const districts = ref([]);
  900. const options = ref([]);
  901. const contractEmpty = {
  902. serviceType: 1,
  903. contractType: 0,
  904. formDate: formatDate(new Date(), "yyyy-MM-dd"),
  905. signerId: useUserStore().user.userId,
  906. signerName: useUserStore().user.nickName,
  907. files: [],
  908. };
  909. const isFullscreen = ref(false);
  910. const webHost = import.meta.env.VITE_APP_BASE_API;
  911. const data = reactive({
  912. form: {},
  913. // rules: {
  914. // contractNo: [
  915. // { required: true, message: "合同编号不能为空", trigger: "blur" },
  916. // ],
  917. // companyId: [{ required: true, message: "请选择有效客户", trigger: "blur" }],
  918. // formDate: [
  919. // { required: editStatus.value ? false : true, message: "签约日期不能为空", trigger: "blur" },
  920. // ],
  921. // amount: [{ required: true, message: "签约金额不能为空", trigger: "blur" }],
  922. // // signerName: [
  923. // // { required: true, message: "签单人不能为空", trigger: "change" },
  924. // // ],
  925. // contractType: [
  926. // { required: true, message: "合同类型不能为空", trigger: "change" },
  927. // ],
  928. // serviceType: [
  929. // { required: true, message: "任务类型不能为空", trigger: "change" },
  930. // ],
  931. // },
  932. });
  933. const rules = computed(() => ({
  934. contractNo: [
  935. { required: true, message: "合同编号不能为空", trigger: "blur" },
  936. ],
  937. companyId: [
  938. { required: type.value == "alterOrder" ? false : true, message: "请选择有效客户", trigger: "blur" },
  939. ],
  940. formDate: [
  941. { required: type.value == "alterOrder" ? false : true, message: "签约日期不能为空", trigger: "blur" },
  942. ],
  943. amount: [
  944. { required: true, message: "签约金额不能为空", trigger: "blur" },
  945. ],
  946. contractType: [
  947. { required: true, message: "合同类型不能为空", trigger: "change" },
  948. ],
  949. serviceType: [
  950. { required: true, message: "任务类型不能为空", trigger: "change" },
  951. ],
  952. party: [
  953. { required: true, message: "乙方不能为空", trigger: "blur" },
  954. ],
  955. }));
  956. const { form, } = toRefs(data);
  957. /*********************** 方法区 ****************************/
  958. onActivated(() => {
  959. getForm();
  960. })
  961. /** 打开抽屉 */
  962. function open(id) {
  963. reset();
  964. visible.value = true;
  965. if (id) {
  966. Promise.all([initTaskTypes(), listSource(), getOrder(id)]).then((res) => {
  967. loopTasks.value = res[0].data.loopTasks;
  968. onceTasks.value = res[0].data.onceTasks;
  969. sourceCategories.value = res[1].rows;
  970. form.value = res[2].data;
  971. type.value =
  972. type.value == "" && form.value.status === 8 ? "alterOrder" : type.value;
  973. parseDetail(form.value.details, form.value);
  974. // console.log(onceDetails.value)
  975. editStatus.value = false;
  976. title.value = "修改订单信息";
  977. initRegion();
  978. });
  979. // getOrder(id).then(response => {
  980. // })
  981. } else {
  982. Promise.all([initTaskTypes(), listSource()]).then((res) => {
  983. loopTasks.value = res[0].data.loopTasks;
  984. onceTasks.value = res[0].data.onceTasks;
  985. sourceCategories.value = res[1].rows;
  986. });
  987. editStatus.value = true;
  988. title.value = "添加订单信息";
  989. }
  990. getOption()
  991. }
  992. function getOption() {
  993. listLableNoPage().then(res => {
  994. options.value = res.data
  995. })
  996. }
  997. const selectedOptionLabel = computed(() => {
  998. const selectedOption = options.value.find(option => option.id === form.value.customerLabelId);
  999. return selectedOption ? selectedOption.lable : '';
  1000. });
  1001. function openSimple(id, optionType) {
  1002. reset();
  1003. visible.value = true;
  1004. type.value = optionType || "";
  1005. if (id) {
  1006. Promise.all([initTaskTypes(), listSource(), getOrder(id)]).then((res) => {
  1007. loopTasks.value = res[0].data.loopTasks;
  1008. onceTasks.value = res[0].data.onceTasks;
  1009. sourceCategories.value = res[1].rows;
  1010. form.value = res[2].data;
  1011. console.log("loopTasks.value", loopTasks.value);
  1012. loopTasks.value.forEach(item => {
  1013. form.value.details.forEach(item2 => {
  1014. if (item2.taskTypeId == item.id) {
  1015. item.isDisabled = item2.disabled
  1016. }
  1017. })
  1018. })
  1019. parseDetail(form.value.details, form.value);
  1020. title.value = "合同变更信息";
  1021. if (type.value != "") {
  1022. editStatus.value = true;
  1023. } else {
  1024. editStatus.value = false;
  1025. }
  1026. });
  1027. } else {
  1028. Promise.all([initTaskTypes(), listSource()]).then((res) => {
  1029. loopTasks.value = res[0].data.loopTasks;
  1030. onceTasks.value = res[0].data.onceTasks;
  1031. sourceCategories.value = res[1].rows;
  1032. });
  1033. editStatus.value = true;
  1034. title.value = "添加订单信息";
  1035. }
  1036. }
  1037. watch(editStatus, (newValue) => {
  1038. console.log('editStatus changed:', newValue);
  1039. });
  1040. /** 取消按钮 */
  1041. function cancel() {
  1042. visible.value = false;
  1043. reset();
  1044. }
  1045. function handleInfo(row) {
  1046. proxy.$refs.companyRef.open(row.companyId);
  1047. }
  1048. /** 表单重置 */
  1049. function reset() {
  1050. form.value = JSON.parse(JSON.stringify(contractEmpty));
  1051. loops.value = [];
  1052. onces.value = [];
  1053. loopDetails.value = [];
  1054. onceDetails.value = [];
  1055. type.value = "";
  1056. proxy.resetForm("orderRef");
  1057. // belong_region.value.forEach(item => {
  1058. // item.id = Number(item.id)
  1059. // })
  1060. }
  1061. /** 全屏缩放 */
  1062. function handleScreen() {
  1063. const dom = document.querySelector(
  1064. ".list-container > .el-drawer__wrapper > .el-overlay"
  1065. );
  1066. isFullscreen.value = !isFullscreen.value;
  1067. dom.style.position = isFullscreen.value ? "fixed" : "absolute";
  1068. }
  1069. function sourceValidator(rule, value, callback) {
  1070. if (form.value.sourceCategoryName === "") {
  1071. callback(new Error("来源类型不能为空"));
  1072. return;
  1073. }
  1074. if (
  1075. form.value.referrerDataSource !== "" &&
  1076. form.value.referrerDataSource != null &&
  1077. form.value.sourceName === ""
  1078. ) {
  1079. callback(new Error("来源不能为空"));
  1080. return;
  1081. }
  1082. return callback();
  1083. }
  1084. /** 提交按钮 */
  1085. function submitForm() {
  1086. const query = { userId: form.value.signerId };
  1087. const users = [];
  1088. listUser(query).then((res) => {
  1089. users.value = res.rows;
  1090. console.log(form.value.signerId);
  1091. // if (users.value.length == 1) {
  1092. // if (
  1093. // form.value.signerId == users.value[0].userId &&
  1094. // form.value.signerName == users.value[0].nickName
  1095. // ) {
  1096. // } else {
  1097. // proxy.$modal.msgError("请选择有效签单人");
  1098. // return;
  1099. // }
  1100. // } else {
  1101. // proxy.$modal.msgError("请选择有效签单人");
  1102. // return;
  1103. // }
  1104. const companyQuery = { id: form.value.companyId };
  1105. const companys = [];
  1106. listCompany(companyQuery).then((res) => {
  1107. companys.value = res.rows;
  1108. if (companys.value.length == 1) {
  1109. if (
  1110. form.value.companyId == companys.value[0].id &&
  1111. form.value.companyName == companys.value[0].name
  1112. ) {
  1113. } else {
  1114. proxy.$modal.msgError("请选择有效客户");
  1115. return;
  1116. }
  1117. } else {
  1118. proxy.$modal.msgError("请选择有效客户");
  1119. return;
  1120. }
  1121. proxy.$refs["orderRef"].validate((valid) => {
  1122. if (valid && detailValid() && amountValid()) {
  1123. const formValue = form.value;
  1124. // formValue.details.forEach(item => {
  1125. // item.timeVo = null
  1126. // })
  1127. formValue.details =
  1128. form.value.serviceType === 1
  1129. ? loopDetails.value
  1130. : onceDetails.value;
  1131. if (formValue.id != null) {
  1132. if (formValue.companyId !== null) {
  1133. if (type.value == "") {
  1134. updateOrder(formValue).then((response) => {
  1135. proxy.$modal.msgSuccess("修改成功");
  1136. visible.value = false;
  1137. getList.value();
  1138. });
  1139. } else if (type.value == "alterOrder") {
  1140. alterOrder(formValue).then((response) => {
  1141. proxy.$modal.msgSuccess("修改成功");
  1142. visible.value = false;
  1143. getList.value();
  1144. });
  1145. } else if (type.value == "dissolutionOrder") {
  1146. dissolutionOrder(formValue).then((response) => {
  1147. proxy.$modal.msgSuccess("修改成功");
  1148. visible.value = false;
  1149. getList.value();
  1150. });
  1151. } else {
  1152. proxy.$modal.msgError("请选择有效客户");
  1153. }
  1154. }
  1155. } else {
  1156. addOrder(formValue).then((response) => {
  1157. proxy.$modal.msgSuccess("新增成功");
  1158. visible.value = false;
  1159. getList.value();
  1160. });
  1161. }
  1162. }
  1163. });
  1164. });
  1165. });
  1166. }
  1167. function detailValid() {
  1168. if (form.value.serviceType === 1) {
  1169. // 循环服务
  1170. if (loopDetails.value.length === 0) {
  1171. proxy.$modal.msgError("请选择至少一条任务");
  1172. return false;
  1173. }
  1174. // loopDetails.forEach((item, index) => {
  1175. for (let i = 0; i < loopDetails.value.length; i++) {
  1176. let item = loopDetails.value[i];
  1177. if (
  1178. (item.freeNum ? Number(item.freeNum) : 0) +
  1179. (item.serviceNum ? Number(item.serviceNum) : 0) <=
  1180. 0
  1181. ) {
  1182. proxy.$modal.msgError(`${item.taskTypeName}服务月数不能为0`);
  1183. return false;
  1184. }
  1185. if (item.price == null || item.price === "") {
  1186. proxy.$modal.msgError(`${item.taskTypeName}请填写服务单价`);
  1187. return false;
  1188. }
  1189. }
  1190. } else if (form.value.serviceType === 2) {
  1191. // 代账服务
  1192. if (onceDetails.value.length === 0) {
  1193. proxy.$modal.msgError("请选择至少一条任务");
  1194. return false;
  1195. }
  1196. for (let i = 0; i < onceDetails.value.length; i++) {
  1197. let item = onceDetails.value[i];
  1198. if (item.payAddress === 1) {
  1199. if (item.addressStyle == null) {
  1200. proxy.$modal.msgError("请选择注册地址类型");
  1201. return false;
  1202. }
  1203. if (
  1204. item.addressStyle === 1 &&
  1205. (item.province == null || item.city == null || item.district == null)
  1206. ) {
  1207. proxy.$modal.msgError("请选择注册区域");
  1208. return false;
  1209. }
  1210. console.log(item);
  1211. if (item.addressStyle === 2 && item.fictionAddressId == null) {
  1212. proxy.$modal.msgError("请选择虚拟地址");
  1213. return false;
  1214. }
  1215. if (item.addressStyle === 2 && item.addressAmount == undefined) {
  1216. proxy.$modal.msgError("请填写虚拟地址金额");
  1217. return false;
  1218. }
  1219. }
  1220. if (
  1221. item.payAddress === 0 &&
  1222. (item.province == null || item.city == null || item.district == null)
  1223. ) {
  1224. proxy.$modal.msgError("请选择办理地区");
  1225. return false;
  1226. }
  1227. for (let j = 0; j < item.processes.length; j++) {
  1228. let process = item.processes[j];
  1229. if (process.amount == undefined) {
  1230. proxy.$modal.msgError(`${process.taskTypeDetailName}请填写金额`);
  1231. return false;
  1232. }
  1233. }
  1234. }
  1235. }
  1236. return true;
  1237. }
  1238. function amountValid() {
  1239. if (form.value.trueAmount < 0) {
  1240. proxy.$modal.msgError("实收金额不可小于0");
  1241. return false;
  1242. }
  1243. return true;
  1244. }
  1245. /** 查询表单信息 */
  1246. function getForm() {
  1247. if(!form.value.id){
  1248. return;
  1249. }
  1250. proxy.$refs.orderRef.resetFields();
  1251. loading.value = true;
  1252. return getOrder(form.value.id).then((response) => {
  1253. loading.value = false;
  1254. form.value = response.data;
  1255. type.value =
  1256. type.value == "" && form.value.status === 8 ? "alterOrder" : type.value;
  1257. });
  1258. }
  1259. function handleServiceTypeClick(tab) {
  1260. computedService();
  1261. }
  1262. function changeDetails(type, arg) {
  1263. switch (type) {
  1264. case "loop":
  1265. arg.forEach((e) => {
  1266. const taskType = loopTasks.value.find((v) => v.id == e);
  1267. if (loopDetails.value.findIndex((v) => v.taskTypeId == e) < 0) {
  1268. const newDetail = JSON.parse(JSON.stringify(detailEmpty));
  1269. newDetail.taskTypeId = e;
  1270. newDetail.taskTypeName = taskType.name;
  1271. loopDetails.value.push(newDetail);
  1272. }
  1273. });
  1274. loopDetails.value = loopDetails.value.filter(
  1275. (v) => arg.findIndex((e) => e == v.taskTypeId) > -1
  1276. );
  1277. computedService()
  1278. break;
  1279. case "once":
  1280. arg.forEach((e) => {
  1281. const taskType = onceTasks.value.find((v) => v.id == e);
  1282. if (onceDetails.value.findIndex((v) => v.taskTypeId == e) < 0) {
  1283. const newDetail = JSON.parse(JSON.stringify(detailEmpty));
  1284. newDetail.taskTypeId = e;
  1285. newDetail.taskTypeName = taskType.name;
  1286. newDetail.payAddress = taskType.payAddress;
  1287. (newDetail.alterType = e === "6" ? "普通变更" : ""),
  1288. (newDetail.defaultProcesses = taskType.processes.map((v) => ({
  1289. taskTypeId: e,
  1290. taskTypeDetailId: v.id,
  1291. taskTypeDetailName: v.name,
  1292. fictionAddressId: null,
  1293. fictionAddress: "",
  1294. addressStyle: 0,
  1295. checked: false,
  1296. amount: undefined,
  1297. })));
  1298. newDetail.processes = [];
  1299. onceDetails.value.push(newDetail);
  1300. }
  1301. });
  1302. onceDetails.value = onceDetails.value.filter(
  1303. (v) => arg.findIndex((e) => e == v.taskTypeId) > -1
  1304. );
  1305. let provincesLength = provincesArr.value.length;
  1306. if (onceDetails.value.length > provincesLength) {
  1307. for (let i = 0; i < onceDetails.value.length - provincesLength; i++) {
  1308. provincesArr.value.push(provinces.value);
  1309. citiesArr.value.push(cities.value);
  1310. districtsArr.value.push(districts.value);
  1311. }
  1312. } else if (onceDetails.value.length < provincesLength) {
  1313. for (let i = 0; i < provincesLength - onceDetails.value.length; i++) {
  1314. provincesArr.value.length--;
  1315. citiesArr.value.length--;
  1316. districtsArr.value.length--;
  1317. }
  1318. }
  1319. break;
  1320. default:
  1321. break;
  1322. }
  1323. }
  1324. function inputChangeHandler(type, field, item, value, parent) {
  1325. console.log(111, type, field, item, value, parent);
  1326. let amount = 0;
  1327. switch (type) {
  1328. case "loop":
  1329. switch (field) {
  1330. case "price":
  1331. amount =
  1332. (item.serviceNum ? Number(item.serviceNum) : 0) *
  1333. (value ? Number(value) : 0) - (item.discountAmount ? Number(item.discountAmount) : 0);
  1334. item.amount = amount;
  1335. break;
  1336. case "serviceNum":
  1337. amount =
  1338. (item.price ? Number(item.price) : 0) * (value ? Number(value) : 0) - (item.discountAmount ? Number(item.discountAmount) : 0);
  1339. item.amount = amount;
  1340. break;
  1341. case "freeNum":
  1342. amount =
  1343. (item.price ? Number(item.price) : 0) *
  1344. (item.serviceNum ? Number(item.serviceNum) : 0) - (item.discountAmount ? Number(item.discountAmount) : 0);
  1345. item.amount = amount;
  1346. break;
  1347. case "discountAmount":
  1348. amount =
  1349. (item.price ? Number(item.price) : 0) *
  1350. (item.serviceNum ? Number(item.serviceNum) : 0) - (value ? Number(value) : 0);
  1351. item.amount = amount;
  1352. }
  1353. break;
  1354. case "once":
  1355. computedItem(item);
  1356. break;
  1357. case "process":
  1358. computedItem(parent);
  1359. break;
  1360. default:
  1361. break;
  1362. }
  1363. computedService();
  1364. }
  1365. function computedItem(parent) {
  1366. let amount = 0;
  1367. amount +=
  1368. parent.payAddress === 1 && parent.addressStyle === 2 && parent.addressAmount
  1369. ? Number(parent.addressAmount)
  1370. : 0;
  1371. amount +=
  1372. parent.taskTypeId === "6" &&
  1373. parent.alterType === "跨区变更" &&
  1374. parent.addressStyle === 2 &&
  1375. parent.addressAmount
  1376. ? Number(parent.addressAmount)
  1377. : 0;
  1378. parent.processes.forEach((l) => {
  1379. amount += l.amount ? Number(l.amount) : 0;
  1380. });
  1381. parent.amount = amount;
  1382. }
  1383. function computedService() {
  1384. //子表中的实际金额
  1385. let amount = 0;
  1386. let discountAmount = 0;
  1387. let trueAmount = 0;
  1388. switch (form.value.serviceType) {
  1389. case 1:
  1390. loopDetails.value.forEach((l) => {
  1391. amount += l.amount;
  1392. discountAmount += l.discountAmount;
  1393. trueAmount += l.trueAmount;
  1394. });
  1395. amount = amount >= 0 ? amount : 0;
  1396. discountAmount = discountAmount >= 0 ? discountAmount : 0;
  1397. break;
  1398. case 2:
  1399. onceDetails.value.forEach((l) => {
  1400. amount +=
  1401. l.payAddress === 1 && l.addressStyle === 2 && l.addressAmount
  1402. ? Number(l.addressAmount)
  1403. : 0;
  1404. if (l.alterType === "跨区变更" && l.addressStyle === 2 && l.addressAmount) {
  1405. amount += Number(l.addressAmount)
  1406. }
  1407. l.processes.forEach((v) => {
  1408. amount += v.amount ? Number(v.amount) : 0;
  1409. });
  1410. });
  1411. break;
  1412. }
  1413. form.value.discountAmount = discountAmount;
  1414. form.value.trueAmount = amount
  1415. form.value.amount = match.add(amount, discountAmount);
  1416. }
  1417. /** 输入框输出建议 */
  1418. function querySearchAsync(queryString, cb) {
  1419. const query = { keyword: queryString };
  1420. listUser(query).then((res) => {
  1421. cb(res.rows);
  1422. });
  1423. }
  1424. function querySearchCompanyAsync(queryString, cb) {
  1425. const query =
  1426. queryString.length > 0
  1427. ? {
  1428. keyword: queryString,
  1429. pageSize: 50,
  1430. pageNum: 1,
  1431. orderByColumn: "create_time",
  1432. }
  1433. : { pageSize: 50, pageNum: 1, orderByColumn: "create_time" };
  1434. listCompany(query).then((res) => {
  1435. cb(res.rows);
  1436. });
  1437. }
  1438. function handleSelectEmployee(item) {
  1439. form.value.signerName = item.nickName;
  1440. form.value.signerId = item.userId;
  1441. }
  1442. function handleSelectCompany(item) {
  1443. console.log(item)
  1444. form.value.companyName = item.name;
  1445. form.value.oldName = item.oldName;
  1446. form.value.companyId = item.id;
  1447. form.value.customerLabelId = item.customerLabelId
  1448. }
  1449. function handleClearCompany() {
  1450. form.value.customerLabelId = "";
  1451. }
  1452. function handleSelectProvince(item, index) {
  1453. const _provinceCode = item.provinceCode;
  1454. const _province = provincesArr.value[index].find((i) => {
  1455. return i.code === _provinceCode;
  1456. });
  1457. item.province = _province.name;
  1458. citiesArr.value[index] = proxy.region.getCities(_provinceCode);
  1459. if (citiesArr.value[index].length === 0) {
  1460. // 清空城市数据
  1461. item.cityCode = "";
  1462. item.city = "";
  1463. cities.value = [{ code: "", name: "全部" }];
  1464. // 清空行政区数据
  1465. item.districtCode = "";
  1466. item.district = "";
  1467. districts.value = [{ code: "", name: "全部" }];
  1468. } else {
  1469. citiesArr.value[index].unshift({ code: "", name: "全部" });
  1470. item.cityCode = citiesArr.value[index][0].code;
  1471. item.city = citiesArr.value[index][0].name;
  1472. handleSelectCity(item, index);
  1473. }
  1474. }
  1475. function handleSelectCity(item, index) {
  1476. const _cityCode = item.cityCode;
  1477. const _city = citiesArr.value[index].find((i) => {
  1478. return i.code === _cityCode;
  1479. });
  1480. item.city = _city.name;
  1481. districtsArr.value[index] = proxy.region.getDistricts(_cityCode);
  1482. if (districtsArr.value[index].length === 0) {
  1483. // 清空行政区数据
  1484. item.districtCode = "";
  1485. item.district = "";
  1486. districtsArr.value[index] = [{ code: "", name: "全部" }];
  1487. } else {
  1488. districtsArr.value[index].unshift({ code: "", name: "全部" });
  1489. item.districtCode = districtsArr.value[index][0].code;
  1490. item.district = districtsArr.value[index][0].name;
  1491. }
  1492. }
  1493. function handleSelectDistrict(item, index) {
  1494. const _districtCode = item.districtCode;
  1495. const _district = districtsArr.value[index].find((i) => {
  1496. return i.code === _districtCode;
  1497. });
  1498. item.district = _district.name;
  1499. }
  1500. function getProcess(item) {
  1501. const typeItem = onceTasks.value.find((i) => i.id === item.taskTypeId);
  1502. return typeItem.processes;
  1503. }
  1504. function checkedProcess(processId, item) {
  1505. const processes = item.processes;
  1506. return processes.findIndex((v) => v.taskTypeDetailId == processId) < 0;
  1507. }
  1508. function changeProcesses(item) {
  1509. computedItem(item);
  1510. computedService();
  1511. }
  1512. function parseDetail(details, form) {
  1513. loops.value = [];
  1514. onces.value = [];
  1515. loopDetails.value = [];
  1516. onceDetails.value = [];
  1517. switch (form.serviceType) {
  1518. case 1:
  1519. // 循环任务
  1520. details.forEach((i) => {
  1521. loops.value.push(i.taskTypeId);
  1522. loopDetails.value.push(i);
  1523. });
  1524. break;
  1525. case 2:
  1526. // 代办任务
  1527. details.forEach((i) => {
  1528. onces.value.push(i.taskTypeId);
  1529. const taskType = onceTasks.value.find((j) => j.id === i.taskTypeId);
  1530. onceDetails.value.push({
  1531. ...i,
  1532. defaultProcesses: parseProcess(i, taskType.processes),
  1533. });
  1534. onceDetails.value.forEach((j) => {
  1535. j.processes = j.defaultProcesses.filter((v) => v.checked);
  1536. });
  1537. });
  1538. break;
  1539. default:
  1540. break;
  1541. }
  1542. }
  1543. function parseProcess(item, processes) {
  1544. return processes.map((l) => {
  1545. // console.log(item.processes.find((i) => i.taskTypeDetailId === l.id));
  1546. if (item.processes.findIndex((i) => i.taskTypeDetailId === l.id) < 0) {
  1547. return {
  1548. taskTypeId: item.taskTypeId,
  1549. taskTypeDetailId: l.id,
  1550. taskTypeDetailName: l.name,
  1551. checked: false,
  1552. amount: undefined,
  1553. };
  1554. } else {
  1555. return {
  1556. ...item.processes.find((i) => i.taskTypeDetailId === l.id),
  1557. checked: true,
  1558. };
  1559. }
  1560. });
  1561. }
  1562. function verifyHandler() {
  1563. proxy.$modal
  1564. .confirm("是否确认审核?")
  1565. .then((_) => {
  1566. // form.value.details.forEach(item => {
  1567. // item.timeVo = null
  1568. // })
  1569. verifyCheckOrder(form.value).then((res) => {
  1570. console.log(123, res);
  1571. if (res.data == null) {
  1572. verifyUpload(1);
  1573. } else {
  1574. verifyOpen.value = true;
  1575. redirectDetails.value = res.data;
  1576. }
  1577. });
  1578. })
  1579. .catch((_) => {
  1580. proxy.$modal.msg("取消审核");
  1581. });
  1582. }
  1583. function verifyFormClose() {
  1584. redirectDetails.value = [];
  1585. verifyForm.value = {};
  1586. verifyOpen.value = false;
  1587. }
  1588. function redirectVerify() {
  1589. redirectDetails.value.forEach((l) => {
  1590. const index = form.value.details.findIndex((v) => v.id === l.id);
  1591. form.value.details[index].redirect = l.redirect;
  1592. });
  1593. verifyUpload(1);
  1594. verifyFormClose();
  1595. }
  1596. function rejectHandler() {
  1597. rejectOpen.value = true;
  1598. }
  1599. function rejectCancel() {
  1600. rejectOpen.value = false;
  1601. }
  1602. function rejectSubmitHandler() {
  1603. if (form.value.verifyRemark === "" || form.value.verifyRemark == null) {
  1604. proxy.$modal.msgError("请填写驳回原因");
  1605. return;
  1606. }
  1607. }
  1608. function verifyUpload(status) {
  1609. const formValue = proxy.deepClone(form.value);
  1610. formValue.verifyStatus = status;
  1611. formValue.status = status;
  1612. verifyOrder(formValue).then((res) => {
  1613. getForm();
  1614. getList.value();
  1615. rejectCancel();
  1616. proxy.$modal.msgSuccess("保存成功");
  1617. });
  1618. }
  1619. /** 文件上传 */
  1620. function upload(param) {
  1621. const formData = new FormData();
  1622. formData.append("file", param.file);
  1623. uploadFile(formData).then((res) => {
  1624. if (res.code === 200) {
  1625. const file = {};
  1626. file.fileName = res.newFileName;
  1627. file.url = res.url;
  1628. file.originalFileName = res.originalFilename;
  1629. file.fileUrl = res.fileName;
  1630. form.value.files.push(file);
  1631. }
  1632. });
  1633. }
  1634. function handleDelFile(index) {
  1635. form.value.files.splice(index, 1);
  1636. }
  1637. function initRegion() {
  1638. console.log("initRegion开始", form.value);
  1639. for (let i = 0; i < form.value.details.length; i++) {
  1640. cities.value = proxy.region.getCities(form.value.details[i].provinceCode);
  1641. cities.value.unshift({ code: "", name: "全部" });
  1642. districts.value = proxy.region.getDistricts(form.value.details[i].cityCode);
  1643. districts.value.unshift({ code: "", name: "全部" });
  1644. console.log("市", cities.value);
  1645. provincesArr.value.push(provinces.value);
  1646. citiesArr.value.push(cities.value);
  1647. districtsArr.value.push(districts.value);
  1648. }
  1649. }
  1650. function showAddCompanyDialog() {
  1651. addCompanyDialogRef.value.open();
  1652. }
  1653. function contractTypeChangeHandler() {
  1654. if (form.value.contractType === 1) {
  1655. form.value.serviceType = 1;
  1656. }
  1657. }
  1658. function showHistoryList() {
  1659. historyChoiceRef.value.open(
  1660. form.value.fromId === "0" ? form.value.id : form.value.fromId
  1661. );
  1662. }
  1663. function historyChoiceHandle(row) {
  1664. open(row.id);
  1665. }
  1666. const timeVoFormat = (timeVo)=>{
  1667. if(null !== timeVo.startTime) {
  1668. return proxy.moment(timeVo.startTime).format("yyyy-MM") + " ~ " + proxy.moment(timeVo.endTime).format("yyyy-MM")
  1669. }else{
  1670. return ""
  1671. }
  1672. }
  1673. const handleResize = (row) => {
  1674. console.log("aa")
  1675. }
  1676. /** 暴露给父组件的方法 */
  1677. defineExpose({
  1678. open,
  1679. openSimple,
  1680. });
  1681. </script>
  1682. <style scoped>
  1683. .my-autocomplete .el-input-group__append {
  1684. padding: 0 10px !important;
  1685. }
  1686. </style>