financeApprove.vue 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363
  1. <template>
  2. <div class="app-container">
  3. <el-dialog
  4. :title="upload.title"
  5. :visible.sync="upload.open"
  6. width="400px"
  7. append-to-body
  8. >
  9. <el-upload
  10. ref="upload"
  11. :limit="1"
  12. accept=".xlsx, .xls"
  13. :headers="upload.headers"
  14. :action="
  15. upload.url +
  16. '?updateSupport=' +
  17. upload.updateSupport +
  18. '&tableName=' +
  19. tableName +
  20. '&sqlKey=' +
  21. tableKey
  22. "
  23. v-loading="upload.isUploading"
  24. :disabled="upload.isUploading"
  25. :on-progress="handleFileUploadProgress"
  26. :on-success="handleFileSuccess"
  27. :auto-upload="false"
  28. :onChange="handleChange"
  29. drag
  30. >
  31. <i class="el-icon-upload"></i>
  32. <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
  33. <div class="el-upload__tip text-center" slot="tip">
  34. <!-- <div class="el-upload__tip" slot="tip">-->
  35. <!-- <el-checkbox v-model="upload.updateSupport"/>-->
  36. <!-- 是否更新已经存在的用户数据-->
  37. <!-- </div>-->
  38. <span>仅允许导入xls、xlsx格式文件。</span>
  39. <el-link
  40. type="primary"
  41. :underline="false"
  42. style="font-size: 12px; vertical-align: baseline"
  43. @click="importTemplate"
  44. >下载模板
  45. </el-link>
  46. </div>
  47. </el-upload>
  48. <div slot="footer" class="dialog-footer">
  49. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  50. <el-button @click="upload.open = false">取 消</el-button>
  51. </div>
  52. </el-dialog>
  53. <Queryfrom
  54. :form-vals="templateInfo.where"
  55. :statisticList="statisticList"
  56. :showCount="showCount"
  57. :showSearch="showSearch"
  58. @getList="getList"
  59. ref="mychild"
  60. />
  61. <el-row :gutter="10" class="mb8">
  62. <el-col :span="1.5">
  63. <el-button
  64. type="primary"
  65. plain
  66. icon="el-icon-s-promotion"
  67. size="mini"
  68. :disabled="multiple"
  69. @click="myDeleteHandler"
  70. >审批
  71. </el-button>
  72. </el-col>
  73. <el-radio-group
  74. style="
  75. display: float;
  76. float: right;
  77. margin-right: 100px;
  78. margin-bottom: 10px;
  79. "
  80. v-model="queryParams.conditionMap.columnValue"
  81. size="mini"
  82. @change="approveTypeChange"
  83. >
  84. <el-radio-button label="8">未审批</el-radio-button>
  85. <el-radio-button label="3,4,5,6,7">已审批</el-radio-button>
  86. <el-radio-button label="7">已驳回</el-radio-button>
  87. <!-- <el-radio-button :label="2">生产</el-radio-button> -->
  88. </el-radio-group>
  89. </el-row>
  90. <el-table
  91. v-loading="loading"
  92. :data="tableList"
  93. @selection-change="handleSelectionChange"
  94. ref="tableRef"
  95. :cell-style="cellStyle"
  96. :reserve-selection="true"
  97. :row-key="getRowKey"
  98. >
  99. <el-table-column
  100. type="selection"
  101. width="55"
  102. reserve-selection
  103. align="center"
  104. >
  105. </el-table-column>
  106. <!-- <span v-for="(key, val) in columns" :key="key">
  107. <el-table-column :label="key" align="center" :prop="val" />
  108. </span> -->
  109. <el-table-column
  110. v-for="item in columns"
  111. :key="item.key"
  112. :label="item.value"
  113. align="center"
  114. :prop="item.key"
  115. >
  116. <template slot-scope="scope">
  117. <!-- 存在字段样式或字典样式 -->
  118. <template
  119. v-if="
  120. scope.row.styleFieldObj != undefined &&
  121. scope.row.styleFieldObj[item.key]
  122. "
  123. >
  124. <!-- 字段样式 -->
  125. <template v-if="scope.row.styleFieldObj[item.key].styleType == 1">
  126. <!-- 一般字体样式 -->
  127. <template
  128. v-if="scope.row.styleFieldObj[item.key].fieldStyleType == 0"
  129. >
  130. <span
  131. :style="`color:${
  132. scope.row.styleFieldObj[item.key].fontColor
  133. }`"
  134. >{{ scope.row[item.key] }}</span
  135. >
  136. </template>
  137. <!-- 标签字体样式 -->
  138. <template
  139. v-else-if="
  140. scope.row.styleFieldObj[item.key].fieldStyleType == 1
  141. "
  142. >
  143. <el-tag
  144. :type="scope.row.styleFieldObj[item.key].tagType"
  145. :effect="
  146. scope.row.styleFieldObj[item.key].isTagFullBg
  147. ? 'dark'
  148. : 'light'
  149. "
  150. >
  151. {{ scope.row[item.key] }}
  152. </el-tag>
  153. </template>
  154. </template>
  155. <!-- 字典样式 -->
  156. <template
  157. v-else-if="scope.row.styleFieldObj[item.key].styleType == 2"
  158. >
  159. <span
  160. v-if="
  161. scope.row.styleFieldObj[item.key].listClass == '' ||
  162. scope.row.styleFieldObj[item.key].listClass == 'default'
  163. "
  164. >{{ scope.row.styleFieldObj[item.key].dictLabel }}</span
  165. >
  166. <el-tag
  167. v-else
  168. :type="
  169. scope.row.styleFieldObj[item.key].listClass == 'primary'
  170. ? ''
  171. : scope.row.styleFieldObj[item.key].listClass
  172. "
  173. >{{ scope.row.styleFieldObj[item.key].dictLabel }}</el-tag
  174. >
  175. </template>
  176. </template>
  177. <!-- 显示默认值 -->
  178. <template v-else>
  179. {{ scope.row[item.key] }}
  180. </template>
  181. </template>
  182. </el-table-column>
  183. <el-table-column
  184. label="操作"
  185. align="center"
  186. class-name="small-padding fixed-width"
  187. >
  188. <template slot-scope="scope">
  189. <!-- <el-button
  190. type="info"
  191. size="default"
  192. @click="handleEdit(scope.$index, scope.row)"
  193. >审批</el-button
  194. > -->
  195. <el-dropdown>
  196. <el-button type="warning" plain size="small">
  197. 处理<i class="el-icon-arrow-down el-icon--right"></i>
  198. </el-button>
  199. <el-dropdown-menu slot="dropdown">
  200. <el-dropdown-item
  201. v-show="queryParams.conditionMap.columnValue == '8'"
  202. >
  203. <el-button
  204. type="text"
  205. size="mini"
  206. @click="handleEdit(scope.$index, scope.row)"
  207. >审批</el-button
  208. >
  209. </el-dropdown-item>
  210. <el-dropdown-item>
  211. <el-button
  212. type="text"
  213. size="mini"
  214. @click="handleDetail(scope.$index, scope.row)"
  215. >详情</el-button
  216. >
  217. </el-dropdown-item>
  218. </el-dropdown-menu>
  219. </el-dropdown>
  220. <Menu
  221. :row="scope.row"
  222. v-for="btnObj in excuteBtnArr"
  223. :key="btnObj.id"
  224. :listAll="btnObj"
  225. @excuteHandler="excuteHandler"
  226. ></Menu>
  227. </template>
  228. </el-table-column>
  229. </el-table>
  230. <pagination
  231. v-show="total > 0"
  232. :total="total"
  233. :page.sync="queryParams.pageNum"
  234. :limit.sync="queryParams.pageSize"
  235. @pagination="pageList"
  236. />
  237. <!-- 添加或修改销售出库单:- 过磅记录生成数据对话框 -->
  238. <el-dialog :title="title" :visible.sync="open" append-to-body>
  239. <el-row :gutter="20">
  240. <el-form
  241. :model="approveForm"
  242. ref="approveFormRef"
  243. :rules="approveRule"
  244. label-width="100px"
  245. :inline="false"
  246. size="normal"
  247. >
  248. <el-col :span="12">
  249. <el-form-item label="是否通过:" prop="status">
  250. <el-radio v-model="approveForm.status" label="3">通过</el-radio>
  251. <el-radio v-model="approveForm.status" label="7">不通过</el-radio>
  252. </el-form-item>
  253. </el-col>
  254. </el-form>
  255. </el-row>
  256. <div slot="footer" class="dialog-footer">
  257. <el-button type="primary" @click="approveConfirm">确 定</el-button>
  258. <el-button @click="cancel">取 消</el-button>
  259. </div>
  260. </el-dialog>
  261. <!-- 绑定按钮dialog -->
  262. <el-dialog
  263. title="提示"
  264. :visible.sync="btnDialogVisible"
  265. :before-close="handleClose"
  266. >
  267. <DialogTemplate
  268. ref="dialogRef"
  269. :groupKey="groupKey"
  270. :rowobj="rowobj"
  271. :subCount="subCount"
  272. :tableCount="tableCount"
  273. :subTableName="subTableName"
  274. @addList="addListHandler"
  275. >
  276. </DialogTemplate>
  277. <span slot="footer" class="dialog-footer">
  278. <el-button @click="btnDialogVisible = false">取 消</el-button>
  279. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  280. </span>
  281. </el-dialog>
  282. <!-- 自定义弹窗 -->
  283. <el-dialog
  284. title="提示"
  285. :visible.sync="btnDialogVisible"
  286. :before-close="handleClose"
  287. >
  288. <DialogTemplate
  289. ref="dialogRef"
  290. :groupKey="groupKey"
  291. :rowobj="rowobj"
  292. :subCount="subCount"
  293. :tableCount="tableCount"
  294. :subTableName="subTableName"
  295. @addList="addListHandler"
  296. >
  297. </DialogTemplate>
  298. <span slot="footer" class="dialog-footer">
  299. <el-button @click="btnDialogVisible = false">取 消</el-button>
  300. <el-button type="primary" @click="btnComfirm">确 定</el-button>
  301. </span>
  302. </el-dialog>
  303. <!-- 详情 -->
  304. <el-dialog title="详情" :visible.sync="detailShow" width="1200px">
  305. <div ref="detailTable" id="detail"></div>
  306. <span slot="footer" class="dialog-footer">
  307. <el-button @click="detailShow = false">取 消</el-button>
  308. <!-- <el-button type="primary" @click="detailPrintHandler">打 印</el-button> -->
  309. </span>
  310. </el-dialog>
  311. </div>
  312. </template>
  313. <script>
  314. import {
  315. delTableData,
  316. dragTableInfo,
  317. listTable,
  318. unionListTableData,
  319. getInfoBySqlKey,
  320. btnCommonApi,
  321. addTableData,
  322. batchEdit,
  323. getStatisticList,
  324. // getTableList2,
  325. getTableList1,
  326. batchApproval,
  327. } from "@/api/tablelist/commonTable";
  328. import { listData } from "@/api/system/tenant/data";
  329. import { getToken } from "@/utils/auth";
  330. import Queryfrom from "@/views/tablelist/commonTable/queryfrom.vue";
  331. import { camelCase, toUnderline } from "@/utils";
  332. import { inputDisableComplete } from "@/utils/other";
  333. import Menu from "@/views/tablelist/commonTable/BtnMenu.vue";
  334. import { checkRole } from "@/utils/permission";
  335. import DialogTemplate from "@/views/dialogTemplate/components/index.vue";
  336. import { queryDropDownBoxData } from "@/api/dragform/form";
  337. import { v4 as uuidv4 } from "uuid";
  338. import { mapState } from "vuex";
  339. export default {
  340. name: "listInfo",
  341. components: { Queryfrom, Menu, DialogTemplate },
  342. dicts: ["sales_order_type", "payment_method", "direction_of_twist"],
  343. data() {
  344. return {
  345. // 详情
  346. detailShow: false,
  347. // 审批相关数据
  348. approveType: "", //审批状态
  349. approveNo: "",
  350. approveForm: {
  351. status: "3",
  352. orderType: "",
  353. saleLeader: "", //业务主管
  354. finance: "", //财务部
  355. production: "", //生产部
  356. saleApprover: "", //批准人
  357. },
  358. approveRule: {
  359. orderType: [
  360. {
  361. required: true,
  362. message: "请选择订单类型",
  363. trigger: "change",
  364. },
  365. ],
  366. },
  367. // 新的自定义数据 start
  368. productIds: [], //货品Ids
  369. isEdit: false,
  370. formData: {
  371. //订单表数据
  372. saleNo: "", //合同号
  373. saleCustomNo: "", //客户编号
  374. saleDate: "", //销售单日期
  375. saleOrderEstimatedTime: "", //预计下单时间
  376. saleLeadTime: "", //交货周期
  377. deliveryDate: "",
  378. saleAmounts: "", //合计金额 小写
  379. saleAmountInWords: "", //合计金额 大写
  380. salePayType: "", //支付方式
  381. earnestMoney: "", //定金
  382. salesman: "", //业务员
  383. saleLeader: "", //业务主管
  384. finance: "", //财务部
  385. production: "", //生产部
  386. saleApprover: "", //批准人
  387. customAddress: "", //客户地址
  388. customCountryType: "", //国家类型
  389. contactPerson: "", //联系人
  390. // 货品明细表数据
  391. productNo: "", //货品号
  392. productName: "", //货品名称
  393. productNumber: "", //销售数量
  394. productWeight: "", //销售重量kg
  395. productUnitPrice: "", //单价
  396. productAmounts: "", //金额
  397. remark: "", //备注
  398. // 工艺表
  399. craftGrid: "", //网格
  400. craftOil: "", //油剂
  401. craftPackage: "", //卷装
  402. craftColorFastness: "", //色牢度
  403. directionOfTwist: "", //捻向
  404. craftOther: "", //其它工艺要求
  405. craftMark: "", //包装/贴唛
  406. shippingMethod: "", //运输方式
  407. },
  408. productionOptions: [],
  409. customerOptions: [],
  410. productionTableData: [
  411. // {
  412. // productNo: "", //货品名称
  413. // productNumber: 2, //销售数量
  414. // productWeight: 1, //销售重量kg
  415. // productUnitPrice: 20, //单价
  416. // productAmounts: 20, //金额
  417. // remark: "", //备注
  418. // },
  419. ],
  420. rules: {},
  421. // end
  422. // 绑定按钮dialog
  423. btnDialogVisible: false,
  424. // 绑定修改dialog
  425. groupKey: "",
  426. // 遮罩层
  427. loading: true,
  428. // 选中数组
  429. ids: [],
  430. // 非单个禁用
  431. single: true,
  432. // 非多个禁用
  433. multiple: true,
  434. // 显示统计
  435. showCount: true,
  436. // 显示搜索条件
  437. showSearch: true,
  438. // 总条数
  439. total: 0,
  440. // 用户表格数据
  441. tableList: [],
  442. // 弹出层标题
  443. title: "",
  444. // 日期范围
  445. dateRange: [],
  446. // 表单参数
  447. form: {},
  448. rules: {},
  449. // cru 弹窗
  450. open: false,
  451. // excel共通导入数据
  452. upload: {
  453. // 是否显示弹出层
  454. open: false,
  455. // 弹出层标题(
  456. title: "",
  457. // 是否禁用上传
  458. isUploading: false,
  459. // 是否更新已经存在的数据
  460. updateSupport: 0,
  461. // 设置上传的请求头部
  462. headers: { Authorization: "Bearer " + getToken() },
  463. // 上传的地址
  464. url: process.env.VUE_APP_BASE_API3 + "common/uploadData",
  465. },
  466. // 排序方式 默认降序
  467. sortOrder: true,
  468. // 共通查询参数接受子组件的参数
  469. queryParams: {
  470. pageNum: 1, // 第几页
  471. pageSize: 10, // 每页大小
  472. orderByColumn: "", // 根据某列排序
  473. isAsc: "", // desc(降序)或 asc(升序)
  474. // 基本查询参数
  475. basicMap: {
  476. tableName: "drag_form",
  477. },
  478. // 当前表字段筛选参数
  479. queryMap: {
  480. // 当前查询基本参数
  481. // ... key : value 当前页面的筛选条件
  482. // 超级查询的唯一值
  483. queryCriteriaValue: "",
  484. },
  485. conditionMap: {
  486. columnName: "status",
  487. columnValue: "8",
  488. },
  489. },
  490. // 列信息
  491. columns: {},
  492. // 当前模版信息
  493. templateInfo: {},
  494. // 查询条件
  495. queryFromWhere: {},
  496. // 当前table唯一标识
  497. tableKey: null,
  498. // 当前表名称
  499. tableName: null,
  500. //存放html代码块
  501. iframeUrl: "",
  502. //存放表单渲染数据
  503. jsonData: {},
  504. // 回显表格数据,
  505. defaultValue: {},
  506. // 统计card
  507. statisticList: [],
  508. // 样式表
  509. styleList: [],
  510. // 字典样式对象
  511. dictStyleObj: {},
  512. // 操作列 按钮数据
  513. excuteBtnArr: [],
  514. // 下拉框动态数据
  515. dynamicData: {},
  516. // 当前点击按钮的数据
  517. currentBtnData: {},
  518. // 修改选中行
  519. rowobj: {},
  520. // 该行的统计信息
  521. subCount: [],
  522. tableCount: [],
  523. // 弹窗新增数据
  524. addLists: [],
  525. subTableName: "",
  526. // 当前点击行的数据
  527. currentRow: {},
  528. // 订单类型list
  529. orderTypeOptions: [],
  530. colourNumberOptions: [], //色号选项
  531. sliceTypeOptions: [], //切片选项
  532. };
  533. },
  534. created() {
  535. // 得到当前展示的table的唯一标识
  536. this.tableKey = this.$route.query.tableKey;
  537. console.log(this.user);
  538. },
  539. watch: {
  540. open(newQuestion, oldQuestion) {
  541. if (newQuestion == false) {
  542. (this.ids = []), this.$refs.tableRef.clearSelection();
  543. }
  544. },
  545. },
  546. computed: {
  547. isShowExcuteCol() {
  548. return !this.excuteBtnArr?.every((arr) => arr.children.length == 0);
  549. },
  550. ...mapState({
  551. nickName: (state) => state.user.nickName,
  552. user: (state) => state.user,
  553. }),
  554. },
  555. methods: {
  556. // 查看详情回调
  557. async handleDetail(index, row) {
  558. this.printDomData = await this.getDetailTableString(row);
  559. this.detailShow = true;
  560. this.$nextTick(() => {
  561. this.$refs.detailTable.innerHTML = this.printDomData;
  562. });
  563. },
  564. getDictLabel(value, dictLsit = []) {
  565. return dictLsit.find((item) => {
  566. return item.value == value;
  567. })?.label;
  568. },
  569. // 获取详情html字符串
  570. async getDetailTableString(row) {
  571. let { saleOrderSaleNo } = row;
  572. let payLoad = [
  573. {
  574. basicMap: {
  575. tableName: "sale_order",
  576. },
  577. conditionMap: {
  578. sale_no: [saleOrderSaleNo],
  579. },
  580. },
  581. {
  582. basicMap: {
  583. tableName: "sale_products",
  584. },
  585. conditionMap: {
  586. sale_order_no: [saleOrderSaleNo],
  587. },
  588. },
  589. {
  590. basicMap: {
  591. tableName: "sale_craft",
  592. },
  593. conditionMap: {
  594. sale_order_no: [saleOrderSaleNo],
  595. },
  596. },
  597. ];
  598. let res = await queryDropDownBoxData(payLoad);
  599. if (res.code == 200) {
  600. console.log(res);
  601. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  602. let {
  603. //订单表数据
  604. saleNo, //合同号
  605. saleCustomNo, //客户编号
  606. saleDate, //销售单日期
  607. saleOrderEstimatedTime, //预计下单时间
  608. saleLeadTime, //交货周期
  609. deliveryDate,
  610. saleAmounts, //合计金额 小写
  611. saleAmountInWords, //合计金额 大写
  612. salePayType, //支付方式
  613. earnestMoney,
  614. salesman, //业务员
  615. saleLeader, //业务主管
  616. finance, //财务部
  617. production, //生产部
  618. saleApprover, //批准人
  619. // customAddress, //客户地址
  620. // customCountryType, //国家类型
  621. // contactPerson, //联系人
  622. // 货品明细表数据
  623. // productNo, //货品号
  624. // productName, //货品名称
  625. // productNumber: "", //销售数量
  626. // productWeight: "", //销售重量kg
  627. // productUnitPrice: "", //单价
  628. // productAmounts: "", //金额
  629. // remark: "", //备注
  630. // 工艺表
  631. craftGrid, //网络
  632. craftOil, //油剂
  633. craftPackage, //卷装
  634. craftColorFastness, //色牢度
  635. directionOfTwist,
  636. craftOther, //其它工艺要求
  637. craftMark, //包装/贴唛
  638. shippingMethod, //运输方式
  639. } = { ...sale_craft[0], ...sale_order[0] };
  640. let customData = this.customerOptions.find(
  641. (item) => item.customNo == saleCustomNo
  642. );
  643. let customerName = customData ? customData.customName : "";
  644. let customAddress = customData?.customAddress || "无";
  645. let customCountryType = customData?.customCountryType || "";
  646. let contactPerson = customData?.contactPerson || "无";
  647. let directionOfTwistDescription = directionOfTwist
  648. ? this.getDictLabel(
  649. directionOfTwist,
  650. this.dict.type.direction_of_twist
  651. )
  652. : "";
  653. let printStr = `
  654. <table style="width:1050px; border-collapse:collapse;" border="1" cellpadding="10" align="center">
  655. <div style="text-align:center;font-size: 20px;">诸暨市新丝维纤维有限公司</div>
  656. <div style="text-align:center;">销售合同审计单</div>
  657. <tbody>
  658. <tr>
  659. <td width="600px" colspan="4">合同号:${saleNo}</td>
  660. <td width="450px" colspan="3">日期:${saleDate.replace(
  661. "T",
  662. " "
  663. )}</td>
  664. </tr>
  665. <tr align="center">
  666. <td width="300px" colspan="2">客户名称:</td>
  667. <td width="300px" colspan="2">${customerName}</td>
  668. <td width="300px" colspan="2">联系人:</td>
  669. <td width="150px" colspan="1">${contactPerson}</td>
  670. </tr>
  671. <tr align="center">
  672. <td width="300px" colspan="2">客户地址:</td>
  673. <td width="300px" colspan="2">${customAddress}</td>
  674. <td width="300px" colspan="2">客户国别:</td>
  675. <td width="150px" colspan="1">${customCountryType}</td>
  676. </tr>
  677. <tr align="center">
  678. <td width="300px" colspan="2">预计下单时间:</td>
  679. <td colspan="1">${saleOrderEstimatedTime.replace(
  680. "T",
  681. " "
  682. )}</td>
  683. <td colspan="1">交货周期:</td>
  684. <td >${saleLeadTime}</td>
  685. <td colspan="1">交货日期:</td>
  686. <td >${deliveryDate.replace("T", " ")}</td>
  687. </tr>
  688. <tr align="center">
  689. <td colspan="7">货品明细</td>
  690. </tr>
  691. <tr align="center">
  692. <td width="150px">品名</td>
  693. <td width="150px">数量/kg</td>
  694. <td width="150px">单价</td>
  695. <td width="150px">金额</td>
  696. <td width="150px">切片型号</td>
  697. <td width="150px">色号</td>
  698. <td width="150px">备注</td>
  699. </tr>`;
  700. let amountTotal = 0,
  701. singlTotal = 0,
  702. moneyTotal = 0;
  703. for (let i = 0; i < sale_products.length; i++) {
  704. let item = sale_products[i];
  705. amountTotal += Number(item.productNumber);
  706. singlTotal += Number(item.productUnitPrice);
  707. moneyTotal += Number(item.productAmounts);
  708. let productData = this.productionOptions.find(
  709. (pro) => pro.productNo == item.productNo
  710. );
  711. console.log("item", item);
  712. item.sliceTypeLabel =
  713. this.sliceTypeOptions.find((k) => k.materielCode == item.sliceType)
  714. ?.materielName || "";
  715. item.colourNumberLabel = this.colourNumberOptions.find(
  716. (k) => k.materielCode == item.colourNumber
  717. )?.materieColorNumber;
  718. let productName = productData ? productData.productName : "";
  719. printStr += `<tr align="center">
  720. <td>${productName}</td>
  721. <td>${item.productNumber}</td>
  722. <td>${item.productUnitPrice}</td>
  723. <td>${item.productAmounts}</td>
  724. <td>${item.sliceTypeLabel}</td>
  725. <td>${item.colourNumberLabel}</td>
  726. <td>${item.remark}</td>
  727. </tr>`;
  728. }
  729. // 计算小计
  730. printStr += `
  731. <tr align="center">
  732. <td>小计:</td>
  733. <td>${amountTotal}</td>
  734. <td>${singlTotal}</td>
  735. <td>${moneyTotal}</td>
  736. <td></td>
  737. <td></td>
  738. <td></td>
  739. </tr>
  740. <tr>
  741. <td colspan="7">合计金额(大写):${saleAmountInWords}</td>
  742. </tr>
  743. `;
  744. if (salePayType == "1") {
  745. //定金
  746. printStr += `
  747. <tr>
  748. <td colspan="4">付款方式:${salePayType}</td>
  749. <td colspan="3">定金:${earnestMoney}</td>
  750. </tr>`;
  751. } else {
  752. printStr += `
  753. <tr>
  754. <td colspan="7">付款方式:${salePayType}</td>
  755. </tr>`;
  756. }
  757. printStr += `<tr align="center">
  758. <td colspan="7">工艺要求</td>
  759. </tr>
  760. <tr align="center">
  761. <td width="150px">网络</td>
  762. <td width="150px">油剂</td>
  763. <td width="150px">卷装</td>
  764. <td width="150px">色牢度</td>
  765. <td width="150px">捻向</td>
  766. <td width="150px">其他</td>
  767. <td width="150px"></td>
  768. </tr>
  769. <tr align="center">
  770. <td >${craftGrid}</td>
  771. <td>${craftOil}</td>
  772. <td>${craftPackage}</td>
  773. <td>${craftColorFastness}</td>
  774. <td>${directionOfTwistDescription}</td>
  775. <td>${craftOther}</td>
  776. <td width="150px"></td>
  777. </tr>
  778. <tr>
  779. <td colspan="7">包装/贴唛:${craftMark}</td>
  780. </tr>
  781. <tr>
  782. <td colspan="7">装运方式:${shippingMethod}</td>
  783. </tr>
  784. <tr align="center">
  785. <td colspan="2">业务员:</td>
  786. <td colspan="2">${salesman}</td>
  787. <td colspan="2">业务主管:</td>
  788. <td>${saleLeader}</td>
  789. </tr>
  790. <tr align="center">
  791. <td colspan="2">财务部:</td>
  792. <td colspan="2">${finance}</td>
  793. <td colspan="2">生产部:</td>
  794. <td>${production}</td>
  795. </tr>
  796. <tr align="center">
  797. <td colspan="2">批准人:</td>
  798. <td colspan="2">${saleApprover}</td>
  799. <td></td>
  800. <td></td>
  801. <td></td>
  802. </tr>
  803. </tbody>
  804. </table>
  805. `;
  806. return printStr;
  807. // <tr align="center">
  808. // <td colspan="2"> 2</td>
  809. // <td> </td>
  810. // <td> </td>
  811. // <td> </td>
  812. // <td> </td>
  813. // </tr>
  814. // <tr>
  815. // <td colspan="2">小计:</td>
  816. // <td></td>
  817. // <td></td>
  818. // <td></td>
  819. // <td></td>
  820. // </tr>
  821. }
  822. },
  823. // 自定义删除按钮
  824. myDeleteHandler(row) {
  825. this.open = true;
  826. },
  827. // 审批状态改变回调
  828. approveTypeChange(status) {
  829. this.getList(false, status);
  830. },
  831. // 审批 开始回调
  832. approveHandler(index, row) {
  833. console.log(row);
  834. },
  835. // 审批 确认回调
  836. approveConfirm() {
  837. // console.log(this.ids);
  838. // return;
  839. // console.log(this.dict.type.sales_order_type);
  840. // console.log(this.approveForm,'approveForm');
  841. // return
  842. this.$refs["approveFormRef"].validate(async (valid) => {
  843. if (valid) {
  844. let payload = {
  845. idList: this.ids,
  846. status: this.approveForm.orderType == "1" ? "5" : "3",
  847. finance: this.nickName,
  848. };
  849. let res = await batchApproval(payload);
  850. if (res.code === 200) {
  851. this.$message.success("审批成功");
  852. this.ids = [];
  853. this.open = false;
  854. this.getList();
  855. } else {
  856. this.$message.error("审批失败");
  857. }
  858. } else {
  859. return false;
  860. }
  861. });
  862. },
  863. // 初始化审批表单数据
  864. initApproveFormData() {
  865. Object.assign(this.approveForm, {
  866. status: "3",
  867. orderType: "",
  868. });
  869. },
  870. // 重置审计表单数据
  871. resetFormData() {
  872. Object.assign(this.formData, {
  873. //订单表数据
  874. saleNo: "", //合同号
  875. saleCustomNo: "", //客户编号
  876. saleDate: "", //销售单日期
  877. saleOrderEstimatedTime: "", //预计下单时间
  878. saleLeadTime: "", //交货周期
  879. deliveryDate: "",
  880. saleAmounts: "", //合计金额 小写
  881. saleAmountInWords: "", //合计金额 大写
  882. salePayType: "", //支付方式
  883. earnestMoney: "",
  884. salesman: "", //业务员
  885. saleLeader: "", //业务主管
  886. finance: "", //财务部
  887. production: "", //生产部
  888. saleApprover: "", //批准人
  889. customAddress: "", //客户地址
  890. customCountryType: "", //国家类型
  891. contactPerson: "", //联系人
  892. // 货品明细表数据
  893. productNo: "", //货品号
  894. productName: "", //货品名称
  895. productNumber: "", //销售数量
  896. productWeight: "", //销售重量kg
  897. productUnitPrice: "", //单价
  898. productAmounts: "", //金额
  899. remark: "", //备注
  900. // 工艺表
  901. craftGrid: "", //网格
  902. craftOil: "", //油剂
  903. craftPackage: "", //卷装
  904. craftColorFastness: "", //色牢度
  905. directionOfTwist: "",
  906. craftOther: "", //其它工艺要求
  907. craftMark: "", //包装/贴唛
  908. shippingMethod: "", //运输方式
  909. });
  910. this.productionTableData = [];
  911. },
  912. // 自定义的小计计算方法
  913. getSummaries(param) {
  914. const { columns, data } = param;
  915. console.log(columns, data);
  916. const sums = [];
  917. columns.forEach((column, index) => {
  918. if (index === 0) {
  919. sums[index] = "小计";
  920. return;
  921. }
  922. const values = data.map((item) => Number(item[column.property]));
  923. if (index === 4 || index === 5 || index === 6 || index === 7) {
  924. sums[index] = "";
  925. } else if (!values.every((value) => isNaN(value))) {
  926. sums[index] = values.reduce((prev, curr) => {
  927. const value = Number(curr);
  928. if (!isNaN(value)) {
  929. return prev + curr;
  930. } else {
  931. return prev;
  932. }
  933. }, 0);
  934. sums[index];
  935. } else {
  936. sums[index] = "N/A";
  937. }
  938. });
  939. return sums;
  940. },
  941. // 货品表格数据删除回调
  942. deleteProduct(index) {
  943. this.productionTableData.splice(index, 1);
  944. },
  945. // 货品表格数据新增回调
  946. addProduct() {
  947. this.productionTableData.push({
  948. saleProductNo: uuidv4(),
  949. productNo: "", //货品编号
  950. productName: "", //货品名称
  951. productNumber: "", //销售数量
  952. productWeight: "", //销售重量kg
  953. productUnitPrice: "", //单价
  954. productAmounts: "", //金额
  955. remark: "", //备注
  956. });
  957. },
  958. // 客户名称改变回调
  959. customChangeHandler(val) {
  960. // if (!val) return;
  961. let customData = this.customerOptions.find(
  962. (item) => item.customNo == val
  963. );
  964. this.formData.customAddress = customData?.customAddress || "无";
  965. this.formData.customCountryType = customData?.customCountryType || "无";
  966. this.formData.contactPerson = customData?.contactPerson || "无";
  967. },
  968. //审计新增
  969. async addHandler() {
  970. this.isEdit = false;
  971. await this.getDropDownData();
  972. this.resetFormData();
  973. this.title = "新增审计单";
  974. this.open = true;
  975. },
  976. // 获取下拉框数据
  977. async getDropDownData() {
  978. try {
  979. let payLoad = [
  980. {
  981. basicMap: {
  982. tableName: "production",
  983. },
  984. },
  985. {
  986. basicMap: {
  987. tableName: "customer",
  988. },
  989. },
  990. ];
  991. let res = await queryDropDownBoxData(payLoad);
  992. if (res.code == 200) {
  993. let { production, customer } = res.data.resultMap;
  994. this.productionOptions = production || [];
  995. this.customerOptions = customer || [];
  996. } else {
  997. throw Error("获取下拉框数据失败");
  998. }
  999. } catch (error) {
  1000. console.log(error);
  1001. }
  1002. // 色号数据
  1003. try {
  1004. let payLoad = [
  1005. {
  1006. basicMap: {
  1007. tableName: "materiel",
  1008. },
  1009. conditionMap: {
  1010. materiel_species: ["1"],
  1011. },
  1012. },
  1013. ];
  1014. let res = await queryDropDownBoxData(payLoad);
  1015. if (res.code == 200) {
  1016. console.log(res.data.resultMap);
  1017. let { materiel } = res.data.resultMap;
  1018. this.colourNumberOptions = materiel || [];
  1019. } else {
  1020. throw Error("获取下拉框数据失败");
  1021. }
  1022. } catch (error) {
  1023. console.log(error);
  1024. }
  1025. // 切片型号
  1026. try {
  1027. let payLoad = [
  1028. {
  1029. basicMap: {
  1030. tableName: "materiel",
  1031. },
  1032. conditionMap: {
  1033. materiel_species: ["6"],
  1034. },
  1035. },
  1036. ];
  1037. let res = await queryDropDownBoxData(payLoad);
  1038. if (res.code == 200) {
  1039. console.log(res.data.resultMap);
  1040. let { materiel } = res.data.resultMap;
  1041. this.sliceTypeOptions = materiel || [];
  1042. } else {
  1043. throw Error("获取下拉框数据失败");
  1044. }
  1045. } catch (error) {
  1046. console.log(error);
  1047. }
  1048. },
  1049. // 获取row-key
  1050. getRowKey(row) {
  1051. return row[
  1052. camelCase(this.tableName + "_" + this.templateInfo.template?.primaryKey)
  1053. ];
  1054. },
  1055. /** 查询列表 */
  1056. getList(queryParams, orderStatus = "") {
  1057. this.loading = true;
  1058. // 序列化当前查询参数列表
  1059. queryParams && (this.queryParams.queryMap = queryParams.queryMap);
  1060. // 获取当前表单结构信息
  1061. dragTableInfo({ queryMap: { tableKey: this.tableKey } })
  1062. .then((res) => {
  1063. // 得到当前模版信息 --- sql columns queryWhere
  1064. this.templateInfo = res.data.resultMap;
  1065. this.styleList = res.data.resultMap.style?.map((item) => {
  1066. item.styleField = camelCase(
  1067. item.styleField.replace(".", "_") || ""
  1068. );
  1069. return item;
  1070. });
  1071. // 获取操作列的按钮数据
  1072. this.excuteBtnArr = res.data.resultMap.button;
  1073. this.queryParams.orderByColumn =
  1074. res.data.resultMap.querySql.orderByColumn;
  1075. this.sortOrder = JSON.parse(res.data.resultMap.querySql.sortOrder);
  1076. // 根据拖拽时设置当前列表排列顺序
  1077. this.queryParams.isAsc = this.sortOrder ? "DESC" : "ASC";
  1078. this.tableName = this.templateInfo.template.dtTableName;
  1079. // 得到查询条件
  1080. this.queryFromWhere = res.data.resultMap.where;
  1081. // 得到当前列表信息
  1082. this.columns = this.columnsHandler(
  1083. JSON.parse(this.templateInfo.template.dtColumnName)
  1084. );
  1085. })
  1086. .finally((fes) => {
  1087. if (this.templateInfo == {}) return;
  1088. // 调用查询需要携带当前table的唯一标识
  1089. this.queryParams.queryMap.sqlkey = this.templateInfo.template.sqlKey;
  1090. this.queryParams.orderByColumn = camelCase(
  1091. this.queryParams.orderByColumn || ""
  1092. );
  1093. // let getListFun = orderStatus ? getTableList2 : unionListTableData;
  1094. // if(){}
  1095. // 根据sql语句查询当前表数据
  1096. let tempQueryParams = JSON.parse(JSON.stringify(this.queryParams));
  1097. console.log(orderStatus);
  1098. if (orderStatus == "3,4,5,6,7" || orderStatus == "7") {
  1099. tempQueryParams.conditionMap.columnName1 = "finance";
  1100. tempQueryParams.conditionMap.columnValue1 =
  1101. "IS NOT NULL and finance != ''";
  1102. }
  1103. getTableList1(tempQueryParams).then(async (res) => {
  1104. this.tableList = [];
  1105. res.rows.forEach((item) => {
  1106. this.tableList.push(item.resultMap);
  1107. });
  1108. // 驼峰转换
  1109. let tempTableList = [];
  1110. tempTableList = this.tableList.map((item) => {
  1111. let kv = {};
  1112. for (let itemKey in item) {
  1113. kv[camelCase(itemKey)] = item[itemKey];
  1114. }
  1115. return kv;
  1116. });
  1117. // this.setDictStyleData().then(() => {
  1118. // this.tableList = this.setFieldStyleData(this.tableList);
  1119. // });
  1120. this.tableList = await this.setFieldStyleData(tempTableList);
  1121. this.total = res.total;
  1122. // this.$nextTick(() => {
  1123. // this.$refs.tableRef?.clearSelection();
  1124. // });
  1125. this.loading = false;
  1126. });
  1127. // 查询统计信息
  1128. getStatisticList({
  1129. queryMap: {
  1130. tableKey: this.templateInfo.template.tableKey,
  1131. queryCriteriaValue: this.queryParams.queryMap.queryCriteriaValue,
  1132. },
  1133. }).then((res) => {
  1134. this.statisticList = res.data;
  1135. });
  1136. });
  1137. },
  1138. // 审计 提交编辑结果按钮回调
  1139. async editConfirm() {
  1140. this.$refs.formDataRef.validate(async (valid) => {
  1141. if (valid) {
  1142. let {
  1143. //订单表数据
  1144. saleCustomNo,
  1145. saleDate,
  1146. saleOrderEstimatedTime,
  1147. saleLeadTime,
  1148. deliveryDate,
  1149. saleAmounts,
  1150. saleAmountInWords,
  1151. salePayType,
  1152. earnestMoney,
  1153. salesman,
  1154. saleLeader,
  1155. finance,
  1156. production,
  1157. saleApprover,
  1158. // 工艺表数据
  1159. craftGrid,
  1160. craftOil,
  1161. craftPackage,
  1162. craftColorFastness,
  1163. directionOfTwist,
  1164. craftOther,
  1165. craftMark,
  1166. shippingMethod,
  1167. } = this.formData;
  1168. let saleCraftNo = this.isEdit ? this.formData.saleCraftNo : uuidv4(),
  1169. saleNo = this.isEdit ? this.formData.saleNo : uuidv4();
  1170. let saleProductsNo = this.productionTableData
  1171. .map((item) => item.saleProductNo)
  1172. .join(","); //销售单表sale_products_no字段存货品表的sale_product_no,逗号分割
  1173. let saleValue = {
  1174. status: 1, //新增销售单时 默认为1
  1175. saleNo,
  1176. saleProductsNo,
  1177. saleOrderTechnologyNo: saleCraftNo,
  1178. saleCustomNo,
  1179. saleDate,
  1180. saleOrderEstimatedTime,
  1181. saleLeadTime,
  1182. deliveryDate,
  1183. // saleAmounts, //合计金额 小写
  1184. saleAmountInWords,
  1185. salePayType,
  1186. earnestMoney,
  1187. salesman,
  1188. saleLeader,
  1189. finance,
  1190. production,
  1191. saleApprover,
  1192. };
  1193. let craftValue = {
  1194. saleOrderNo: saleNo,
  1195. saleCraftNo,
  1196. craftGrid,
  1197. craftOil,
  1198. craftPackage,
  1199. craftColorFastness,
  1200. directionOfTwist,
  1201. craftOther,
  1202. craftMark,
  1203. shippingMethod,
  1204. };
  1205. let saleData = {
  1206. //订单表新增数据
  1207. basicMap: {
  1208. tableName: "sale_order",
  1209. },
  1210. // addListMap: [saleValue],
  1211. conditionMap: {},
  1212. commMap: {},
  1213. btnParametersMap: {},
  1214. };
  1215. let craftData = {
  1216. //工艺表新增数据
  1217. basicMap: {
  1218. tableName: "sale_craft",
  1219. },
  1220. // addListMap: [craftValue],
  1221. conditionMap: {},
  1222. commMap: {},
  1223. btnParametersMap: {},
  1224. };
  1225. this.productionTableData.forEach((item) => {
  1226. item.saleOrderNo = saleNo;
  1227. });
  1228. let productData = {
  1229. //货品表新增数据
  1230. basicMap: {
  1231. tableName: "sale_products",
  1232. },
  1233. addListMap: [...this.productionTableData],
  1234. conditionMap: {},
  1235. commMap: {},
  1236. btnParametersMap: {},
  1237. };
  1238. if (this.isEdit) {
  1239. //修改
  1240. Object.keys(saleValue).map((k) => {
  1241. saleData.commMap[k] = saleValue[k];
  1242. });
  1243. Object.keys(craftValue).map((k) => {
  1244. craftData.commMap[k] = craftValue[k];
  1245. });
  1246. saleData.conditionMap.saleNo = saleValue.saleNo;
  1247. craftData.conditionMap.saleCraftNo = craftValue.saleCraftNo;
  1248. // for(let i = 0;i<this.)
  1249. let deletPayload = {
  1250. //删除货品数据的接口
  1251. basicMap: {
  1252. tableName: "sale_products",
  1253. },
  1254. conditionMap: {
  1255. saleProductNo: this.productIds,
  1256. },
  1257. };
  1258. let delRes = { code: 200 };
  1259. if (this.productIds.length) {
  1260. delRes = await delTableData(deletPayload); //删除旧数据
  1261. }
  1262. let updateSaleRes = await batchEdit(saleData);
  1263. let updateCraftRes = await batchEdit(craftData);
  1264. let addProductRes = { code: 200 };
  1265. if (productData.addListMap.length) {
  1266. addProductRes = await addTableData(productData);
  1267. }
  1268. console.log(delRes, updateSaleRes, updateCraftRes, addProductRes);
  1269. if (
  1270. delRes?.code === 200 &&
  1271. updateSaleRes?.code === 200 &&
  1272. updateCraftRes?.code === 200 &&
  1273. addProductRes?.code === 200
  1274. ) {
  1275. this.$message.success("修改成功");
  1276. this.open = false;
  1277. this.getList();
  1278. } else {
  1279. this.$message.error("修改失败");
  1280. }
  1281. } else {
  1282. //新增
  1283. saleData.addListMap = [saleValue];
  1284. craftData.addListMap = [craftValue];
  1285. let saleRes = await addTableData(saleData);
  1286. let craftRes = await addTableData(craftData);
  1287. let productRes = await addTableData(productData);
  1288. if (
  1289. saleRes.code === 200 &&
  1290. craftRes.code === 200 &&
  1291. productRes.code === 200
  1292. ) {
  1293. this.$message.success("添加成功");
  1294. this.open = false;
  1295. this.getList();
  1296. } else {
  1297. this.$message.error("添加失败");
  1298. }
  1299. }
  1300. // Object.keys(saleValue).map((k) => {
  1301. // saleData.commMap[k] = saleValue[k];
  1302. // });
  1303. }
  1304. });
  1305. },
  1306. // 审计 编辑回调
  1307. async handleEdit(index, row) {
  1308. console.log(11111);
  1309. console.log(this.ids);
  1310. console.log(this.dict.type.sales_order_type);
  1311. console.log(row);
  1312. let orderTypeRes = await listData({
  1313. isEnablePaging: false,
  1314. dictType: "sales_order_type",
  1315. });
  1316. if (orderTypeRes.code == 200) {
  1317. this.orderTypeOptions = orderTypeRes.rows?.map((item) => {
  1318. return {
  1319. label: item.dictLabel,
  1320. value: item.dictValue,
  1321. };
  1322. });
  1323. }
  1324. let { saleOrderSaleNo, saleOrderId, saleOrderOrderType } = row;
  1325. this.ids.push(saleOrderId);
  1326. this.approveForm.orderType = saleOrderOrderType;
  1327. this.approveNo = saleOrderSaleNo;
  1328. try {
  1329. let payLoad = [
  1330. {
  1331. basicMap: {
  1332. tableName: "sale_order",
  1333. },
  1334. conditionMap: {
  1335. sale_no: [saleOrderSaleNo],
  1336. },
  1337. },
  1338. {
  1339. basicMap: {
  1340. tableName: "sale_products",
  1341. },
  1342. conditionMap: {
  1343. sale_order_no: [saleOrderSaleNo],
  1344. },
  1345. },
  1346. {
  1347. basicMap: {
  1348. tableName: "sale_craft",
  1349. },
  1350. conditionMap: {
  1351. sale_order_no: [saleOrderSaleNo],
  1352. },
  1353. },
  1354. ];
  1355. let res = await queryDropDownBoxData(payLoad);
  1356. if (res.code == 200) {
  1357. this.isEdit = true;
  1358. let { sale_craft, sale_order, sale_products } = res.data.resultMap;
  1359. Object.assign(this.formData, {
  1360. ...sale_craft[0],
  1361. ...sale_order[0],
  1362. });
  1363. let { saleDate, saleOrderEstimatedTime } = sale_order[0];
  1364. saleDate && (this.formData.saleDate = new Date(saleDate));
  1365. saleOrderEstimatedTime &&
  1366. (this.formData.saleOrderEstimatedTime = saleOrderEstimatedTime);
  1367. this.productionTableData = sale_products;
  1368. this.productIds = sale_products.map((item) => item.saleProductNo);
  1369. await this.getDropDownData();
  1370. this.title = "编辑审计单";
  1371. this.open = true;
  1372. }
  1373. } catch (error) {
  1374. console.log(error);
  1375. }
  1376. },
  1377. // 审计 批量删除回调
  1378. async batchDelete() {
  1379. if (!this.ids.length) return;
  1380. try {
  1381. await this.$confirm("是否确认删除选中的数据?", "警告", {
  1382. confirmButtonText: "确定",
  1383. cancelButtonText: "取消",
  1384. type: "warning",
  1385. });
  1386. let orderPayload = {
  1387. basicMap: {
  1388. tableName: "sale_order",
  1389. },
  1390. conditionMap: {
  1391. saleNo: this.ids,
  1392. },
  1393. };
  1394. let productsPayload = {
  1395. basicMap: {
  1396. tableName: "sale_products",
  1397. },
  1398. conditionMap: {
  1399. saleOrderNo: this.ids,
  1400. },
  1401. };
  1402. let craftPayload = {
  1403. basicMap: {
  1404. tableName: "sale_craft",
  1405. },
  1406. conditionMap: {
  1407. saleOrderNo: this.ids,
  1408. },
  1409. };
  1410. let orderRes = await delTableData(orderPayload);
  1411. let productRes = await delTableData(productsPayload);
  1412. let craftRes = await delTableData(craftPayload);
  1413. if (
  1414. orderRes.code == 200 &&
  1415. productRes.code == 200 &&
  1416. craftRes.code == 200
  1417. ) {
  1418. this.$message.success("删除成功");
  1419. this.getList();
  1420. } else {
  1421. this.$message.error("删除失败");
  1422. throw Error("删除失败");
  1423. }
  1424. } catch (error) {
  1425. console.log(error);
  1426. }
  1427. },
  1428. isUpperCase(char) {
  1429. return char === char.toUpperCase();
  1430. },
  1431. // 下划线命名转驼峰命名
  1432. toUnderScoreCase(str) {
  1433. if (str === null) {
  1434. return null;
  1435. }
  1436. let sb = "";
  1437. // 前置字符是否大写
  1438. let preCharIsUpperCase = true;
  1439. // 当前字符是否大写
  1440. let curreCharIsUpperCase = true;
  1441. // 下一字符是否大写
  1442. let nexteCharIsUpperCase = true;
  1443. for (let i = 0; i < str.length; i++) {
  1444. let c = str.charAt(i);
  1445. if (i > 0) {
  1446. preCharIsUpperCase = isUpperCase(str.charAt(i - 1));
  1447. } else {
  1448. preCharIsUpperCase = false;
  1449. }
  1450. curreCharIsUpperCase = isUpperCase(c);
  1451. if (i < str.length - 1) {
  1452. nexteCharIsUpperCase = isUpperCase(str.charAt(i + 1));
  1453. }
  1454. if (
  1455. preCharIsUpperCase &&
  1456. curreCharIsUpperCase &&
  1457. !nexteCharIsUpperCase
  1458. ) {
  1459. sb += SEPARATOR;
  1460. } else if (i !== 0 && !preCharIsUpperCase && curreCharIsUpperCase) {
  1461. sb += SEPARATOR;
  1462. }
  1463. sb += c.toLowerCase();
  1464. }
  1465. return sb;
  1466. },
  1467. // 处理列表信息
  1468. columnsHandler(columns) {
  1469. let resArr = [];
  1470. columns.forEach((item) => {
  1471. for (const key in item) {
  1472. let tempObj = {};
  1473. tempObj.key = camelCase(key);
  1474. tempObj.value = item[key];
  1475. resArr.push(tempObj);
  1476. }
  1477. });
  1478. return resArr;
  1479. },
  1480. // 取消按钮
  1481. cancel() {
  1482. this.open = false;
  1483. // this.reset();
  1484. },
  1485. // 分页查询
  1486. pageList(row) {
  1487. // 调用子组件-》携带子组件参数请求后台
  1488. this.$refs.mychild.pageList(
  1489. row == undefined
  1490. ? {
  1491. limit: this.queryParams.pageSize,
  1492. page: this.queryParams.pageNum,
  1493. }
  1494. : row
  1495. );
  1496. },
  1497. // 多选框选中数据
  1498. handleSelectionChange(selection) {
  1499. // this.ids = selection.map(
  1500. // (item) =>
  1501. // item[
  1502. // camelCase(
  1503. // this.tableName + "_" + this.templateInfo.template?.primaryKey
  1504. // )
  1505. // ]
  1506. // );
  1507. this.ids = selection.map((item) => item.saleOrderId);
  1508. this.single = selection.length != 1;
  1509. this.multiple = !selection.length;
  1510. },
  1511. // 更多操作触发
  1512. handleCommand(command, row) {
  1513. switch (command) {
  1514. case "handleResetPwd":
  1515. this.handleResetPwd(row);
  1516. break;
  1517. case "handleAuthRole":
  1518. this.handleAuthRole(row);
  1519. break;
  1520. default:
  1521. break;
  1522. }
  1523. },
  1524. /** 新增按钮操作 */
  1525. handleAdd(row) {
  1526. // this.reset();
  1527. this.defaultValue = {};
  1528. getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1529. if (!data || !data.dfVueTemplate) {
  1530. this.jsonData = false;
  1531. this.$message.error("当前表格未绑定表单!");
  1532. return;
  1533. }
  1534. if (data.dfFormSql) {
  1535. let dynamicData = JSON.parse(data.dfFormSql);
  1536. Object.assign(this.dynamicData, dynamicData);
  1537. }
  1538. this.jsonData = JSON.parse(data.dfVueTemplate);
  1539. this.open = true;
  1540. this.title = "添加信息";
  1541. this.form.password = this.initPassword;
  1542. this.$nextTick(() => {
  1543. this.$refs.addFromRef.reset();
  1544. inputDisableComplete();
  1545. });
  1546. });
  1547. },
  1548. longestCommonSubstring(strs) {
  1549. if (!strs || strs.includes("")) return "";
  1550. let str1_Length = strs[0].length;
  1551. let str_Nums = strs.length;
  1552. let flag = 0;
  1553. for (let i = 0; i < str1_Length && flag == 0; i++) {
  1554. let char = strs[0][i];
  1555. for (var j = 1; j < str_Nums; j++) {
  1556. if (char !== strs[j][i] || i == strs[j].length) {
  1557. return strs[1].substring(0, i);
  1558. }
  1559. }
  1560. }
  1561. return strs[0];
  1562. },
  1563. // 绑定dialog对话框关闭
  1564. handleClose() {
  1565. this.btnDialogVisible = false;
  1566. },
  1567. getLastUppercaseWord(text) {
  1568. const pattern = /\b[A-Z][a-z]*\b/g;
  1569. const matches = [...text.matchAll(pattern)];
  1570. if (matches.length > 0) {
  1571. const lastMatch = matches[matches.length - 1][0];
  1572. return lastMatch;
  1573. } else {
  1574. return null;
  1575. }
  1576. },
  1577. /** 修改按钮操作 */
  1578. async handleUpdate(row, btnData) {
  1579. let nameTable = this.templateInfo.template.dtTableName;
  1580. this.rowobj = {};
  1581. let obj = {};
  1582. for (let key in row) {
  1583. let modifiedTable = key
  1584. .replace(/[A-Z]/g, (match) => `_${match}`)
  1585. .toLowerCase();
  1586. this.rowobj[modifiedTable] = row[key];
  1587. let str = modifiedTable.substring(nameTable.length + 1);
  1588. obj[str] = row[key];
  1589. }
  1590. // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1591. // if (!data || !data.dfVueTemplate) {
  1592. // this.$message.error("当前表格未绑定表单!");
  1593. // return;
  1594. // }});
  1595. // 新的修改请求
  1596. try {
  1597. let payLoad = {
  1598. basicMap: {
  1599. btnType: this.currentBtnData.btnType,
  1600. btnKey: this.currentBtnData.btnKey,
  1601. visible: "false",
  1602. sqlKey: this.templateInfo.template.sqlKey,
  1603. tableName: this.tableName,
  1604. },
  1605. conditionMap: {},
  1606. };
  1607. let primary = camelCase(
  1608. this.tableName + "_" + this.templateInfo.template?.primaryKey
  1609. );
  1610. payLoad.conditionMap[this.templateInfo.template?.primaryKey] =
  1611. row[primary];
  1612. let res = await btnCommonApi(payLoad);
  1613. // 判断是否绑定dialog弹窗
  1614. if (!this.currentBtnData.btnTableFormGroupKey) {
  1615. if (!res.data || !res.data.template) {
  1616. this.$message.error("当前按钮未绑定表单!");
  1617. return;
  1618. }
  1619. res.data.template.dfFormSql &&
  1620. (this.dynamicData = JSON.parse(res.data.template.dfFormSql));
  1621. this.addRealFieldName(res.data.result.resultMap);
  1622. let resultMap = res.data.result.resultMap;
  1623. Object.assign(this.defaultValue, resultMap);
  1624. this.jsonData = JSON.parse(res.data.template.dfVueTemplate);
  1625. this.open = true;
  1626. this.title = "修改信息";
  1627. this.form.password = this.initPassword;
  1628. this.$nextTick(() => {
  1629. this.$refs.addFromRef.setData(res.data.result.resultMap);
  1630. });
  1631. } else {
  1632. this.subTableName = res.data.result.dragTables[1].dtTableName;
  1633. this.btnDialogVisible = true;
  1634. this.groupKey = this.currentBtnData.btnTableFormGroupKey;
  1635. this.$nextTick(() => {
  1636. let refChild = this.$refs.dialogRef;
  1637. refChild.getLists(this.groupKey);
  1638. });
  1639. let tablesubKey = res.data.result.dragTables[1].tableKey;
  1640. // 查询统计信息
  1641. getStatisticList({
  1642. queryMap: {
  1643. tableKey: tablesubKey,
  1644. },
  1645. }).then((res) => {
  1646. this.subCount = res.data;
  1647. });
  1648. let prmKey = this.templateInfo.template.primaryKey;
  1649. let pkey = prmKey.replace(/_([a-z])/g, (match, p1) =>
  1650. p1.toUpperCase()
  1651. );
  1652. let data = {
  1653. queryMap: {
  1654. tableKey: res.data.result.dragTables[2].tableKey,
  1655. },
  1656. };
  1657. let key =
  1658. "#{" +
  1659. this.templateInfo.template.dtTableName +
  1660. "." +
  1661. this.templateInfo.template.primaryKey;
  1662. data.queryMap[key] =
  1663. "'" + obj[this.templateInfo.template.primaryKey] + "'";
  1664. getStatisticList(data).then((res) => {
  1665. this.tableCount = res.data;
  1666. });
  1667. }
  1668. // let fieldList = Object.keys(resultMap);
  1669. // let tableName = this.longestCommonSubstring(fieldList);
  1670. // fieldList.forEach((field) => {
  1671. // let realField = field.replace(tableName, "");
  1672. // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1673. // resultMap[realField] = resultMap[field];
  1674. // });
  1675. } catch (error) {
  1676. this.$message.error("网络异常,请稍后再试");
  1677. console.log(error);
  1678. }
  1679. return;
  1680. // getInfoBySqlKey(this.templateInfo.template.sqlKey).then(({ data }) => {
  1681. // if (!data || !data.dfVueTemplate) {
  1682. // this.$message.error("当前表格未绑定表单!");
  1683. // return;
  1684. // }
  1685. // // let fieldList = Object.keys(row);
  1686. // // let tableName = this.longestCommonSubstring(fieldList);
  1687. // // fieldList.forEach((field) => {
  1688. // // let realField = field.replace(tableName, "");
  1689. // // realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1690. // // row[realField] = row[field];
  1691. // // });
  1692. // this.addRealFieldName(row);
  1693. // Object.assign(this.defaultValue, row);
  1694. // this.jsonData = JSON.parse(data.dfVueTemplate);
  1695. // this.open = true;
  1696. // this.title = "修改信息";
  1697. // this.form.password = this.initPassword;
  1698. // this.$nextTick(() => {
  1699. // this.$refs.addFromRef.setData(row);
  1700. // });
  1701. // });
  1702. // return;
  1703. this.reset();
  1704. const userId = row.userId || this.ids;
  1705. getUser(userId).then((response) => {
  1706. this.form = response.data;
  1707. this.postOptions = response.posts;
  1708. this.roleOptions = response.roles;
  1709. this.$set(this.form, "postIds", response.postIds);
  1710. this.$set(this.form, "roleIds", response.roleIds);
  1711. this.open = true;
  1712. this.title = "修改当前信息";
  1713. this.form.password = "";
  1714. });
  1715. },
  1716. // 添加真正的字段名
  1717. addRealFieldName(row) {
  1718. let fieldList = Object.keys(row);
  1719. // let tableName = this.longestCommonSubstring(fieldList);
  1720. let tableName = camelCase(this.tableName);
  1721. fieldList.forEach((field) => {
  1722. let realField = field.replace(tableName, "");
  1723. realField = realField[0].toLocaleLowerCase() + realField.substring(1);
  1724. row[realField] = row[field];
  1725. });
  1726. },
  1727. /** 提交按钮 */
  1728. submitForm: function () {
  1729. this.$refs["form"].validate((valid) => {
  1730. if (valid) {
  1731. if (this.form.userId != undefined) {
  1732. updateUser(this.form).then((response) => {
  1733. this.$modal.msgSuccess("修改成功");
  1734. this.open = false;
  1735. this.getList();
  1736. });
  1737. } else {
  1738. addUser(this.form).then((response) => {
  1739. this.$modal.msgSuccess("新增成功");
  1740. this.open = false;
  1741. this.getList();
  1742. });
  1743. }
  1744. }
  1745. });
  1746. },
  1747. /** 删除按钮操作
  1748. *
  1749. * 删除提示信息语句(标识)
  1750. * */
  1751. handleDelete(row, btnData) {
  1752. let delIds = this.ids;
  1753. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1754. // let realyKey=
  1755. this.addRealFieldName(row);
  1756. if (row[primary] != undefined && row[primary] != null) {
  1757. delIds = [];
  1758. delIds.push(row[primary]);
  1759. }
  1760. let data = {
  1761. basicMap: {
  1762. btnType: btnData.btnType,
  1763. btnKey: btnData.btnKey,
  1764. tableName: this.tableName,
  1765. },
  1766. conditionMap: {
  1767. // id: delIds,
  1768. },
  1769. btnParametersMap: {},
  1770. };
  1771. if (this.currentBtnData.btnParams) {
  1772. let btnParams =
  1773. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  1774. let conditionData =
  1775. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  1776. conditionData.forEach((item) => {
  1777. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  1778. ? item.fieldValue
  1779. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1780. });
  1781. btnParams.forEach((item) => {
  1782. data.btnParametersMap[item.fieldName.split(".")[1]] = item.fieldValue
  1783. ? item.fieldValue
  1784. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  1785. });
  1786. }
  1787. // data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  1788. this.$modal
  1789. .confirm('是否确认删除"' + delIds + '"的数据项?')
  1790. .then(function () {
  1791. // return delTableData(data);
  1792. return btnCommonApi(data);
  1793. })
  1794. .then(() => {
  1795. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  1796. this.$refs.mychild.pageList();
  1797. this.$modal.msgSuccess("删除成功");
  1798. })
  1799. .catch(() => {});
  1800. },
  1801. // 批量删除接口
  1802. handleBatchDelete() {
  1803. let delIds = this.ids;
  1804. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1805. // if (row && row[primary] != undefined && row[primary] != null) {
  1806. // delIds = [];
  1807. // delIds.push(row[primary]);
  1808. // }
  1809. let data = {
  1810. basicMap: {
  1811. tableName: this.tableName,
  1812. },
  1813. conditionMap: {
  1814. // id: delIds,
  1815. },
  1816. };
  1817. // if (this.currentBtnData.btnParams) {
  1818. // let btnParams = JSON.parse(this.currentBtnData.btnParams);
  1819. // btnParams.forEach((item) => {
  1820. // data.btnParametersMap[
  1821. // this.formatField(item.fieldName, camelCase(this.tableName))
  1822. // ] = item.fieldValue
  1823. // ? item.fieldValue
  1824. // : this.currentRow[item.fieldName];
  1825. // });
  1826. // }
  1827. data.conditionMap[this.templateInfo.template?.primaryKey] = delIds;
  1828. this.$modal
  1829. .confirm('是否确认删除"' + delIds + '"的数据项?')
  1830. .then(function () {
  1831. return delTableData(data);
  1832. // return btnCommonApi(data);
  1833. })
  1834. .then(() => {
  1835. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  1836. this.$refs.mychild.pageList();
  1837. this.$modal.msgSuccess("删除成功");
  1838. })
  1839. .catch(() => {});
  1840. },
  1841. /** 导出按钮操作 */
  1842. handleExport() {
  1843. let primary = camelCase(this.templateInfo.template?.primaryKey);
  1844. let realyKey = camelCase(this.tableName + "_" + primary);
  1845. if (this.ids.length > 0) {
  1846. this.queryParams["execlMap"] = [];
  1847. this.ids.forEach((item) => {
  1848. this.queryParams.execlMap.push(
  1849. this.tableList.find((ttem) => {
  1850. return ttem[realyKey] === item;
  1851. })
  1852. );
  1853. });
  1854. } else {
  1855. this.$message.warning("请至少勾选一条导出数据");
  1856. return;
  1857. }
  1858. this.queryParams.execlMap = JSON.stringify(this.queryParams.execlMap);
  1859. this.download(
  1860. process.env.VUE_APP_BASE_API3 + "common/export",
  1861. {
  1862. ...this.queryParams,
  1863. },
  1864. `文件名称_${new Date().getTime()}.xlsx`
  1865. );
  1866. },
  1867. /** 导入按钮操作 */
  1868. handleImport() {
  1869. this.upload.title = "当前导入";
  1870. this.upload.open = true;
  1871. },
  1872. /** 下载模板操作 */
  1873. importTemplate() {
  1874. this.download(
  1875. process.env.VUE_APP_BASE_API3 +
  1876. `common/exportTemplate?tableName=${this.tableName}&sqlkey=${this.templateInfo.template.sqlKey}`,
  1877. {},
  1878. `下载模版名称${new Date().getTime()}.xlsx`
  1879. );
  1880. },
  1881. // 文件上传中处理
  1882. handleFileUploadProgress(event, file, fileList) {
  1883. this.upload.isUploading = true;
  1884. },
  1885. // 文件上传成功处理
  1886. handleFileSuccess(response, file, fileList) {
  1887. this.upload.open = false;
  1888. this.upload.isUploading = false;
  1889. this.$refs.upload.clearFiles();
  1890. this.$alert(
  1891. "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
  1892. response.msg +
  1893. "</div>",
  1894. "导入结果",
  1895. { dangerouslyUseHTMLString: true }
  1896. );
  1897. this.$refs.mychild.pageList({
  1898. limit: this.queryParams.pageSize,
  1899. page: this.queryParams.pageNum,
  1900. });
  1901. },
  1902. //重点在这里
  1903. handleChange(file, fileList) {
  1904. file.name = this.tableName + "." + file.name.split(".")[1];
  1905. fileList.forEach((item) => {
  1906. item.name = this.tableName + "." + file.name.split(".")[1];
  1907. });
  1908. let newFile = new File(
  1909. [file],
  1910. this.tableName + "." + file.name.split(".")[1]
  1911. ); //创建出来也是不可编辑的file对象
  1912. },
  1913. // 提交上传文件
  1914. submitFileForm() {
  1915. this.$refs.upload.submit();
  1916. },
  1917. // 弹窗新增的数
  1918. addListHandler(val) {
  1919. this.addLists.push(...val);
  1920. },
  1921. // 绑定弹窗Dialog确定按钮
  1922. btnComfirm() {
  1923. // let data = {
  1924. // addListMap:[],
  1925. // basicMap:{
  1926. // btnType: 10,
  1927. // tableName: this.subTableName,
  1928. // visible: true,
  1929. // },
  1930. // commMap: {},
  1931. // conditionMap: {},
  1932. // }
  1933. // // data.addListMap =
  1934. // btnCommonApi(data).then(res => {
  1935. // console.log('弹窗确定', res);
  1936. // })
  1937. },
  1938. // 去掉表名 开头字母小写
  1939. formatField(field = "", tableName) {
  1940. let temp = field.replace(tableName, "");
  1941. return toUnderline(temp[0].toLowerCase() + temp.slice(1));
  1942. },
  1943. //提交编辑结果按钮回调
  1944. async editConfirmHandler() {
  1945. if (this.$refs.addFromRef) {
  1946. this.$refs.addFromRef
  1947. .getData()
  1948. .then(async (values) => {
  1949. let data = {
  1950. basicMap: {
  1951. tableName: this.tableName,
  1952. // btnKey: btnData.btnKey,
  1953. btnKey: this.currentBtnData.btnKey,
  1954. },
  1955. addListMap: [values],
  1956. conditionMap: {},
  1957. commMap: {},
  1958. btnParametersMap: {},
  1959. };
  1960. if (this.currentBtnData.btnParams) {
  1961. let btnParams =
  1962. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData ||
  1963. [];
  1964. let conditionData =
  1965. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  1966. // let
  1967. btnParams.forEach((item) => {
  1968. data.btnParametersMap[item.fieldName.split(".")[1]] =
  1969. item.fieldValue
  1970. ? item.fieldValue
  1971. : this.currentRow[
  1972. camelCase(item.fieldName.replace(".", "_"))
  1973. ];
  1974. });
  1975. conditionData.forEach((item) => {
  1976. data.conditionMap[item.fieldName.split(".")[1]] =
  1977. item.fieldValue
  1978. ? item.fieldValue
  1979. : this.currentRow[
  1980. camelCase(item.fieldName.replace(".", "_"))
  1981. ];
  1982. });
  1983. }
  1984. if (Object.keys(this.defaultValue).length) {
  1985. // data.conditionMap[this.templateInfo.template?.primaryKey] =
  1986. // this.defaultValue[this.templateInfo.template?.primaryKey];
  1987. Object.keys(values).map((k) => {
  1988. data.commMap[k] = values[k];
  1989. });
  1990. data.basicMap.btnType = this.currentBtnData.btnType;
  1991. data.basicMap.visible = true;
  1992. } else {
  1993. data.basicMap.btnType = "INSERT";
  1994. data.basicMap.visible = true;
  1995. }
  1996. try {
  1997. let res = await btnCommonApi(data);
  1998. if (res.code == 200) {
  1999. this.$message.success("操作成功");
  2000. } else {
  2001. this.$message.error("网络异常,请稍后再试");
  2002. }
  2003. } catch (error) {
  2004. console.log(error);
  2005. this.$message.error("网络异常,请稍后再试");
  2006. }
  2007. this.getList();
  2008. this.defaultValue = {};
  2009. this.open = false;
  2010. })
  2011. .catch((res) => {
  2012. console.log(res);
  2013. this.$modal.msgError("表单校验失败,请规范填写数据");
  2014. });
  2015. } else {
  2016. // 没有绑定表单
  2017. let data = {
  2018. basicMap: {
  2019. tableName: this.tableName,
  2020. // btnKey: btnData.btnKey,
  2021. btnKey: this.currentBtnData.btnKey,
  2022. btnType: this.currentBtnData.btnType,
  2023. visible: true,
  2024. },
  2025. addListMap: [],
  2026. conditionMap: {},
  2027. commMap: {},
  2028. btnParametersMap: {},
  2029. };
  2030. if (this.currentBtnData.btnParams) {
  2031. let btnParams =
  2032. JSON.parse(this.currentBtnData.btnParams)?.commonFieldData || [];
  2033. let conditionData =
  2034. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2035. conditionData.forEach((item) => {
  2036. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2037. ? item.fieldValue
  2038. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2039. });
  2040. btnParams.forEach((item) => {
  2041. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2042. item.fieldValue
  2043. ? item.fieldValue
  2044. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2045. });
  2046. }
  2047. // data.basicMap.btnType = this.currentBtnData.btnType;
  2048. // data.basicMap.visible = true;
  2049. try {
  2050. let res = await btnCommonApi(data);
  2051. if (res.code == 200) {
  2052. this.$message.success("操作成功");
  2053. } else {
  2054. this.$message.error("网络异常,请稍后再试");
  2055. }
  2056. } catch (error) {
  2057. console.log(error);
  2058. this.$message.error("网络异常,请稍后再试");
  2059. }
  2060. this.getList();
  2061. this.defaultValue = {};
  2062. this.open = false;
  2063. }
  2064. },
  2065. // 使用提交数据类型的按钮获取数据
  2066. tempSubBtn(getData) {
  2067. getData()
  2068. .then((values) => {
  2069. console.log("验证通过", values);
  2070. })
  2071. .catch(() => {
  2072. console.log("验证未通过,获取失败");
  2073. });
  2074. },
  2075. // 判断是否生效行样式
  2076. cellStyle({ row, column, rowIndex, columnIndex }) {
  2077. let rowStyleList = this.styleList.filter((item) => item.styleType == 0);
  2078. if (!rowStyleList.length) return "";
  2079. let mainTableName = this.templateInfo.querySql.tableAlias; //主表名
  2080. for (let i = 0; i < rowStyleList.length; i++) {
  2081. let item = rowStyleList[i];
  2082. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2083. if (judgeRes) {
  2084. let styleCode = JSON.parse(item.styleCode);
  2085. return `background-color:${styleCode.rowBgColor};`;
  2086. }
  2087. }
  2088. },
  2089. // 获取生效条件组结果
  2090. determineCondition(conditionStr, row) {
  2091. let conditionList = JSON.parse(conditionStr);
  2092. if (!conditionList.length) return false;
  2093. return conditionList.every((item) => this.judgeOneCondition(item, row));
  2094. },
  2095. // 获取单个判断条件结果
  2096. judgeOneCondition(item, row) {
  2097. let fullField = camelCase(item.tableName + "_" + item.fieldName);
  2098. switch (item.condition) {
  2099. case 1:
  2100. return row[fullField] > item.flagValue;
  2101. case 2:
  2102. return row[fullField] < item.flagValue;
  2103. case 3:
  2104. return row[fullField] == item.flagValue;
  2105. case 4:
  2106. return row[fullField] >= item.flagValue;
  2107. case 5:
  2108. return row[fullField] <= item.flagValue;
  2109. default:
  2110. return true; //默认为true
  2111. }
  2112. },
  2113. // 设置表格字段样式
  2114. async setFieldStyleData(tableList) {
  2115. console.log(JSON.parse(JSON.stringify(tableList)));
  2116. let fieldConditionList = this.styleList.filter(
  2117. (item) => item.styleType == 1 || item.styleType == 2
  2118. );
  2119. if (!fieldConditionList.length) return tableList;
  2120. let res = await this.setDictStyleData();
  2121. this.dictStyleObj = res.reduce((pre, item) => {
  2122. return {
  2123. ...pre,
  2124. ...item,
  2125. };
  2126. }, {});
  2127. // console.log("this.dictStyleObj", this.dictStyleObj);
  2128. tableList.forEach((row) => {
  2129. // if (!row.styleFieldObj) row.styleFieldObj = {};
  2130. for (let i = 0; i < fieldConditionList.length; i++) {
  2131. let item = fieldConditionList[i];
  2132. if (item.styleType == 1) {
  2133. //字段样式
  2134. let judgeRes = this.determineCondition(item.styleCondtion, row);
  2135. if (judgeRes) {
  2136. let styleCode = JSON.parse(item.styleCode);
  2137. if (!row.styleFieldObj) row.styleFieldObj = {};
  2138. row.styleFieldObj[item.styleField] = {
  2139. styleType: item.styleType,
  2140. fieldStyleType: styleCode.fieldStyleType,
  2141. fontColor: styleCode.fontColor,
  2142. isTagFullBg: styleCode.isTagFullBg,
  2143. tagType: styleCode.tagType,
  2144. };
  2145. // row.styleField = item.styleField; //样式生效字段
  2146. // row.styleType = item.styleType; //0:行样式 1:字段样式 2:字典样式
  2147. // row.fieldStyleType = styleCode.fieldStyleType; //0:文本 1:标签
  2148. // row.fontColor = styleCode.fontColor;
  2149. // row.isTagFullBg = styleCode.isTagFullBg; //true/false
  2150. // row.tagType = styleCode.tagType; //string
  2151. }
  2152. } else {
  2153. //字典样式
  2154. let dicStyle = this.dictStyleObj[item.styleField]?.find((dict) => {
  2155. return dict.dictValue == row[item.styleField];
  2156. });
  2157. if (dicStyle) {
  2158. if (!row.styleFieldObj) row.styleFieldObj = {};
  2159. row.styleFieldObj[item.styleField] = dicStyle; //设置该字段应该显示的字典样式
  2160. row.styleFieldObj[item.styleField].styleType = 2;
  2161. }
  2162. }
  2163. }
  2164. });
  2165. return tableList;
  2166. },
  2167. //设置表格字典相关数据
  2168. setDictStyleData() {
  2169. let fieldConditionList = this.styleList.filter(
  2170. (item) => item.styleType == 2
  2171. );
  2172. if (!fieldConditionList.length) return;
  2173. let PromiseList = fieldConditionList.map((item) => {
  2174. return new Promise((resolve, reject) => {
  2175. let temp = {};
  2176. try {
  2177. listData({
  2178. isEnablePaging: false,
  2179. dictType: item.styleCondtion,
  2180. }).then((res) => {
  2181. temp[item.styleField] = res.rows;
  2182. resolve(temp);
  2183. });
  2184. } catch (error) {
  2185. reject(error);
  2186. }
  2187. });
  2188. });
  2189. return Promise.all(PromiseList);
  2190. },
  2191. // 内链页面跳转
  2192. routerHandler(btnData, type) {
  2193. let { url, commonFieldData } = JSON.parse(btnData.btnParams);
  2194. let tempArr = [];
  2195. if (commonFieldData) {
  2196. let queryArr = JSON.parse(commonFieldData);
  2197. tempArr = queryArr.map((item) => {
  2198. let key = this.formatField(item.fieldName, camelCase(this.tableName));
  2199. let value = item.fieldValue
  2200. ? item.fieldValue
  2201. : this.currentRow[item.fieldName];
  2202. return key + "=" + value;
  2203. });
  2204. }
  2205. if (tempArr.length) {
  2206. url += "?" + tempArr.join("&");
  2207. }
  2208. // let link = btnData.btnParams;
  2209. if (type == "INNERLINK") {
  2210. this.$router.push(url);
  2211. } else {
  2212. window.open("http://" + url, "_blank");
  2213. }
  2214. },
  2215. // 操作列回调
  2216. excuteHandler(btnData, row) {
  2217. console.log("btnData", btnData, row);
  2218. let { btnType, btnParams, btnFormType } = btnData;
  2219. this.currentBtnData = btnData;
  2220. this.currentRow = JSON.parse(JSON.stringify(row));
  2221. // 无表单
  2222. if (btnFormType == "noNeed") {
  2223. this.noNeedHandler(btnData, row);
  2224. return;
  2225. }
  2226. switch (btnType) {
  2227. case "INNERLINK":
  2228. this.routerHandler(btnData, btnType);
  2229. break;
  2230. case "OUTLINK":
  2231. this.routerHandler(btnData, btnType);
  2232. break;
  2233. case "UPDATE":
  2234. this.handleUpdate(row, btnData);
  2235. break;
  2236. case "EXECUTE":
  2237. this.handleUpdate(row, btnData);
  2238. break;
  2239. case "INITIATED":
  2240. this.handleUpdate(row, btnData);
  2241. break;
  2242. case "DELETE":
  2243. this.handleDelete(row, btnData);
  2244. break;
  2245. default:
  2246. break;
  2247. }
  2248. },
  2249. noNeedHandler(btnData, row) {
  2250. this.$modal
  2251. .confirm("是否确认执行该操作?")
  2252. .then(async () => {
  2253. // 获取默认参数
  2254. let data = {
  2255. basicMap: {
  2256. tableName: this.tableName,
  2257. // btnKey: btnData.btnKey,
  2258. btnKey: this.currentBtnData.btnKey,
  2259. },
  2260. conditionMap: {},
  2261. commMap: {},
  2262. btnParametersMap: {},
  2263. };
  2264. console.log(this.currentBtnData, this.currentRow);
  2265. if (this.currentBtnData.btnParams) {
  2266. let conditionData =
  2267. JSON.parse(this.currentBtnData.btnParams).conditionData || [];
  2268. // let
  2269. let commonData =
  2270. JSON.parse(this.currentBtnData.btnParams).commonFieldData || [];
  2271. conditionData.forEach((item) => {
  2272. data.conditionMap[item.fieldName.split(".")[1]] = item.fieldValue
  2273. ? item.fieldValue
  2274. : this.currentRow[camelCase(item.fieldName.replace(".", "_"))];
  2275. });
  2276. commonData.forEach((item) => {
  2277. data.btnParametersMap[item.fieldName.split(".")[1]] =
  2278. item.fieldValue
  2279. ? item.fieldValue
  2280. : this.currentRow[
  2281. camelCase(item.fieldName.replace(".", "_"))
  2282. ];
  2283. });
  2284. }
  2285. data.basicMap.btnType = this.currentBtnData.btnType;
  2286. data.basicMap.visible = true;
  2287. try {
  2288. let res = await btnCommonApi(data);
  2289. if (res.code == 200) {
  2290. this.$message.success(res.msg);
  2291. } else {
  2292. this.$message.error("网络异常,请稍后再试");
  2293. }
  2294. } catch (error) {
  2295. console.log(error);
  2296. this.$message.error("网络异常,请稍后再试");
  2297. }
  2298. })
  2299. .then(() => {
  2300. // 调用子组件查询方法 目的是携带上子组件中的查询参数
  2301. this.$refs.mychild.pageList();
  2302. // this.$modal.msgSuccess("操作成功");
  2303. })
  2304. .catch(() => {});
  2305. },
  2306. // k-form-build表单变化回调
  2307. formChangeHandler(value, label) {
  2308. // console.log(value, label);
  2309. },
  2310. },
  2311. };
  2312. </script>
  2313. <style scoped lang="scss">
  2314. ::v-deep .el-dialog:not(.is-fullscreen) {
  2315. min-width: 610px !important;
  2316. }
  2317. </style>