add.html 78 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571
  1. {extend name="common/common2" /}
  2. {block name="main"}
  3. <style>
  4. .ctable td{
  5. min-width: 150px!important;
  6. max-width: 300px!important;
  7. }
  8. </style>
  9. <div class="row">
  10. <div class="col-sm-12">
  11. <div class="ibox float-e-margins">
  12. <!--<div class="ibox-title">-->
  13. <!--<h5>{$meta_title}</h5>-->
  14. <!--<div class="ibox-tools">-->
  15. <!--<a class="toback" href="{:url('index')}">-->
  16. <!--返回上一页-->
  17. <!--</a>-->
  18. <!--</div>-->
  19. <!--</div>-->
  20. <div class="ibox-content" id="vue-plan">
  21. <p><br></p>
  22. <div class="row">
  23. <div class="col-xs-6 col-xs-offset-3">
  24. <el-steps :active="step" align-center finish-status="success">
  25. <el-step title="配置检查内容"></el-step>
  26. <el-step title="配置排班"></el-step>
  27. <el-step title="任务确认"></el-step>
  28. </el-steps>
  29. </div>
  30. </div>
  31. <p><br></p>
  32. <form method="post" class="form-horizontal">
  33. <div v-if="step == 0">
  34. <div class="form-group">
  35. <label class="col-sm-2 control-label">任务名称<span class="text-danger">*</span></label>
  36. <div class="col-sm-8">
  37. <input type="text" class="form-control" v-model="title" value="" placeholder="请输入任务名称">
  38. </div>
  39. </div>
  40. <div class="form-group">
  41. <label class="col-sm-2 control-label">计划时间<span class="text-danger">*</span></label>
  42. <div class="col-sm-8">
  43. <el-date-picker
  44. style="width: 100%"
  45. size="small"
  46. v-model="date"
  47. type="daterange"
  48. range-separator="至"
  49. value-format="yyyy-MM-dd"
  50. start-placeholder="开始日期"
  51. end-placeholder="结束日期">
  52. </el-date-picker>
  53. </div>
  54. </div>
  55. <div class="form-group">
  56. <label class="col-sm-2 control-label">检查内容<span class="text-danger">*</span></label>
  57. <div class="col-sm-8">
  58. <button class="btn btn-sm btn-primary" type="button" @click="addGroup">添加检查内容</button>
  59. <!-- <button class="btn btn-sm btn-primary" type="button" @click="selectAddr()">添加地点</button>-->
  60. <!-- <button class="btn btn-sm btn-primary" type="button" @click="selectForm()">设置检查内容</button>-->
  61. <!-- <button class="btn btn-sm btn-danger" type="button" @click="delAddrs">移除</button>-->
  62. <!-- <button class="btn btn-sm btn-primary" type="button" @click="sortAddrs">确定排序</button>-->
  63. <el-table
  64. v-if="tableData.length > 0"
  65. :data="tableData"
  66. height="350"
  67. border
  68. @selection-change="handleSelectionChange"
  69. style="width: 100%">
  70. <el-table-column
  71. type="selection"
  72. width="60">
  73. </el-table-column>
  74. <el-table-column
  75. prop="addrTitle"
  76. label="检查内容">
  77. </el-table-column>
  78. <!-- <el-table-column prop="formTitle" label="检查内容">-->
  79. <!-- <template slot-scope="scope">-->
  80. <!-- <span v-for="(item,index) in scope.row.forms" :key="index">{{item.title}};</span>-->
  81. <!-- </template>-->
  82. <!-- </el-table-column>-->
  83. <el-table-column prop="sorts" label="排序">
  84. <template slot-scope="scope">
  85. <input type="number" step="1" class="form-control" v-model="scope.row.sorts">
  86. </template>
  87. </el-table-column>
  88. <!-- <el-table-column label="操作" width="180">-->
  89. <!-- <template slot-scope="scope">-->
  90. <!-- <button class="btn btn-sm" type="button" @click="moveUp(scope.$index, scope.row)">上移</button>-->
  91. <!-- <button class="btn btn-sm" type="button" @click="moveDown(scope.$index, scope.row)">下移</button>-->
  92. <!-- </template>-->
  93. <!-- </el-table-column>-->
  94. </el-table>
  95. </div>
  96. <div class="col-sm-12">
  97. <input type="hidden" name="group" value="" id="groupbox">
  98. <table class="table table-bordered">
  99. <thead>
  100. <tr>
  101. <th style="width: 25%">检查内容</th>
  102. <th style="width: 25%">检查项</th>
  103. <th style="width: 15%">关联业务</th>
  104. <th style="width: 25%">业务项</th>
  105. <th style="width: 10%" class="text-center">操作</th>
  106. </tr>
  107. </thead>
  108. <tbody>
  109. <tr v-for="(item,index) in groups" :key="index">
  110. <td>
  111. <textarea v-model="item.title" rows="1" class="form-control" style="height: 100%"></textarea>
  112. </td>
  113. <td>
  114. <button type="button" :id="`formsbtn${index}`" :url="`{:url('QualityForm/selectforms',[],false,false)}/idx/${index}`" onclick="selectForms(this)" class="btn btn-sm btn-primary">选择表单项</button>
  115. <div v-if="item.forms.length > 0">
  116. <div v-for="(vo,idx) in item.forms" :key="idx" class="alert alert-success alert-dismissable" style="padding: 5px;margin-bottom: 5px;width: 90%;">
  117. <button class="close" @click="delForms(index,vo.id)" type="button">×</button>
  118. <span v-if="Number(vo.type) == 1">
  119. [选择框]{{vo.title}}
  120. </span>
  121. <span v-if="Number(vo.type) == 0">
  122. [输入框]{{vo.title}}
  123. </span>
  124. </div>
  125. </div>
  126. </td>
  127. <td>
  128. <select v-model="item.type" class="form-control" @change="changeType(index,item)">
  129. <option value="0">不关联业务</option>
  130. <option value="1">巡更</option>
  131. <option value="2">巡视</option>
  132. <option value="3">巡查</option>
  133. <option value="4">巡检</option>
  134. <option value="5">日常工作</option>
  135. <option value="6">设备台账</option>
  136. </select>
  137. </td>
  138. <td>
  139. <button type="button" :id="`bussbtn${index}`" url="" onclick="selectBuss(this)" class="btn btn-sm btn-primary">选择关联项</button>
  140. <div v-if="item.buss.length > 0">
  141. <div v-for="(vo,idx) in item.buss" :key="idx" class="alert alert-success alert-dismissable" style="padding: 5px;margin-bottom: 5px;width: 90%;">
  142. <button class="close" @click="delBuss(index,vo.id)" type="button">×</button>
  143. {{vo.title}}
  144. </div>
  145. </div>
  146. </td>
  147. <td class="text-center">
  148. <a href="javascript:;" @click="delGroup(index)" class="btn btn-danger btn-sm">删除</a>
  149. </td>
  150. </tr>
  151. </tbody>
  152. </table>
  153. </div>
  154. </div>
  155. <!--<div class="form-group">
  156. <label class="col-sm-2 control-label">是否按顺序执行<span class="text-danger">*</span></label>
  157. <div class="col-sm-8" style="padding-top: 7px;">
  158. <el-radio v-model="inOrder" :label="0">否</el-radio>
  159. <el-radio v-model="inOrder" :label="1">是</el-radio>
  160. </div>
  161. </div>
  162. <div class="form-group" v-if="inOrder === 1 && lines.length > 0">
  163. <label class="col-sm-2 control-label">路线时间设置</label>
  164. <div class="col-sm-8" style="padding-top: 7px;">
  165. <table class="table table-bordered ctable text-center">
  166. <tr>
  167. <th class="text-center">路线</th>
  168. <th class="text-center">时间跨度(分钟)</th>
  169. <th class="text-center">浮动时间(分钟)</th>
  170. </tr>
  171. <tr v-for="(item,index) in lines" :key="index">
  172. <td>{{item.st}} ~ {{item.et}}</td>
  173. <td><el-input type="number" v-model="item.kd" size="small" style="width: 140px" placeholder=""></el-input></td>
  174. <td><el-input type="number" v-model="item.fd" size="small" style="width: 140px" placeholder=""></el-input></td>
  175. </tr>
  176. </table>
  177. </div>
  178. </div>-->
  179. </div>
  180. <div v-if="step == 1">
  181. <div class="form-group">
  182. <label class="col-sm-2 control-label">设置人员<span class="text-danger">*</span></label>
  183. <div class="col-sm-8">
  184. <el-select
  185. v-model="userIds"
  186. multiple
  187. collapse-tags
  188. style="width: 100%"
  189. size="small"
  190. placeholder="请选择">
  191. <el-option
  192. v-for="item in users"
  193. :key="item.id"
  194. :label="item.title"
  195. :value="item.id">
  196. </el-option>
  197. </el-select>
  198. </div>
  199. </div>
  200. <div class="form-group">
  201. <label class="col-sm-2 control-label">时间段配置<span class="text-danger">*</span></label>
  202. <div class="col-sm-8">
  203. <el-select v-model="dateType" placeholder="请选择" style="width: 100px;" size="small">
  204. <el-option
  205. v-for="item in dateTypes"
  206. :key="item.id"
  207. :label="item.title"
  208. :value="item.id">
  209. </el-option>
  210. </el-select>
  211. <span v-if="dateType == 3">
  212. <el-date-picker
  213. style="width: 130px"
  214. size="small"
  215. v-model="dateFrom"
  216. type="date"
  217. value-format="yyyy-MM-dd"
  218. placeholder="请选择日期">
  219. </el-date-picker>
  220. 开始,工作
  221. <el-input type="number" @input="changePlay" v-model="datePlay" size="small" style="width: 80px;" placeholder="请输入天数"></el-input>
  222. 天,
  223. 暂停
  224. <el-input type="number" @input="changePause" v-model="datePause" size="small" style="width: 80px;" placeholder="请输入天数"></el-input>
  225. 天,每天的
  226. </span>
  227. <button v-if="dateType == 2" class="btn btn-sm btn-default" type="button" @click="selectWeek">添加周</button>
  228. <button class="btn btn-sm btn-default" type="button" @click="selectTime">添加时间段</button>
  229. 开始任务
  230. <div v-if="dateType == 2" style="padding: 5px 0">
  231. 已选择周:
  232. <el-tag
  233. style="margin-right: 5px;cursor: pointer"
  234. v-for="item in dateWeeks"
  235. size="small"
  236. :key="item.id"
  237. :type="item.type"
  238. effect="dark"
  239. >
  240. {{ item.title }}
  241. </el-tag>
  242. </div>
  243. <div style="padding: 5px 0">
  244. 已选择时间段:
  245. <el-tag
  246. style="margin-right: 5px;margin-bottom: 5px"
  247. :key="index"
  248. v-for="(item,index) in dateTimes"
  249. size="small"
  250. >
  251. {{item.stime}} ~ <span v-if="item.stype == 1">{{item.sday}}天后</span>{{item.etime}}
  252. </el-tag>
  253. </div>
  254. <el-button @click="createClass" size="small">生成任务表</el-button>
  255. <div style="padding: 5px 0">
  256. <div class="table-responsive" v-if="tasks.list.length > 0">
  257. <table class="table table-bordered ctable text-center">
  258. <tr>
  259. <td></td>
  260. <td v-for="(item,index) in tasks.days" :key="index">{{item}}</td>
  261. </tr>
  262. <tr v-for="(vo,idx) in tasks.list" :key="idx">
  263. <td>{{vo.time.stime}} ~ <span v-if="vo.time.stype == 1">{{vo.time.sday}}天后</span>{{vo.time.etime}}</td>
  264. <td v-for="(item,index) in tasks.days" :key="index">
  265. <template v-for="(v,id) in vo.list">
  266. <span v-if="item == v.day" :key="id">{{v.userNames}}</span>
  267. </template>
  268. </td>
  269. </tr>
  270. </table>
  271. </div>
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. <div v-if="step == 2">
  277. <div style="padding: 5px 0">
  278. <div class="table-responsive" v-if="tasks.list.length > 0">
  279. <table class="table table-bordered ctable text-center">
  280. <tr>
  281. <td></td>
  282. <td></td>
  283. <td v-for="(item,index) in tasks.days" :key="index"><a href="javascript:;" @click="delDay(item)">删除列</a></td>
  284. </tr>
  285. <tr>
  286. <td></td>
  287. <td></td>
  288. <td v-for="(item,index) in tasks.days" :key="index">{{item}}</td>
  289. </tr>
  290. <tr v-for="(vo,idx) in tasks.list" :key="idx">
  291. <td><a href="javascript:;" @click="delTimes(vo.time)">删除行</a></td>
  292. <td>{{vo.time.stime}} ~ <span v-if="vo.time.stype == 1">{{vo.time.sday}}日后</span>{{vo.time.etime}}</td>
  293. <td v-for="(item,index) in tasks.days" :key="index">
  294. <template v-for="(v,id) in vo.list">
  295. <span v-if="item == v.day" :key="id">{{v.userNames}}</span>
  296. </template>
  297. </td>
  298. </tr>
  299. </table>
  300. </div>
  301. </div>
  302. </div>
  303. <div class="hr-line-dashed"></div>
  304. <div class="form-group">
  305. <div class="col-sm-6 col-sm-offset-2">
  306. <button v-if="step == 2" class="btn btn-primary" target-form="form-horizontal" type="button" id="saveSubmit" @click="saveSubmit">保 存</button>
  307. <button v-if="step == 1||step == 2" class="btn btn-default" type="button" @click="pre">上一步</button>
  308. <button v-if="step == 0||step == 1" class="btn btn-info" type="button" @click="next">下一步</button>
  309. </div>
  310. </div>
  311. </form>
  312. <el-dialog
  313. title="选择地点"
  314. :visible.sync="dialogVisibleAddr"
  315. width="500px"
  316. :before-close="handleClose"
  317. >
  318. <el-input
  319. placeholder="请输入"
  320. v-model="addrkeyword"
  321. @input="searchAddr"
  322. clearable>
  323. </el-input>
  324. <el-table
  325. ref="singleTable"
  326. :data="addrs"
  327. height="300"
  328. @selection-change="handleSelectionChangeAddr"
  329. style="width: 100%">
  330. <el-table-column
  331. type="selection"
  332. width="60">
  333. </el-table-column>
  334. <el-table-column
  335. property="title"
  336. label="名称"
  337. >
  338. </el-table-column>
  339. </el-table>
  340. <span slot="footer" class="dialog-footer">
  341. <el-button @click="dialogVisibleAddr = false">取 消</el-button>
  342. <el-button type="primary" @click="saveAddr">确 定</el-button>
  343. </span>
  344. </el-dialog>
  345. <el-dialog
  346. title="选择检查内容"
  347. :visible.sync="dialogVisibleForm"
  348. width="500px"
  349. :before-close="handleCloseForm"
  350. >
  351. <el-input
  352. placeholder="请输入"
  353. v-model="formkeyword"
  354. @input="searchForm"
  355. clearable>
  356. </el-input>
  357. <el-table
  358. v-if="dialogVisibleForm"
  359. ref="singleTable2"
  360. :data="forms"
  361. height="300"
  362. @selection-change="handleCurrentChange"
  363. style="width: 100%">
  364. <el-table-column
  365. type="selection"
  366. width="60">
  367. </el-table-column>
  368. <el-table-column
  369. property="title"
  370. label="名称"
  371. >
  372. </el-table-column>
  373. </el-table>
  374. <span slot="footer" class="dialog-footer">
  375. <el-button @click="handleCloseForm">取 消</el-button>
  376. <el-button type="primary" @click="saveForm">确 定</el-button>
  377. </span>
  378. </el-dialog>
  379. <el-dialog
  380. title="选择周"
  381. :visible.sync="dialogVisibleWeek"
  382. width="500px"
  383. :before-close="handleCloseWeek"
  384. >
  385. <div class="text-center">
  386. <el-tag
  387. style="margin-right: 5px;cursor: pointer"
  388. v-for="item in weeks"
  389. size="small"
  390. :key="item.id"
  391. :type="item.type"
  392. effect="dark"
  393. @click="handleWeek(item)"
  394. >
  395. {{ item.title }}
  396. </el-tag>
  397. </div>
  398. <span slot="footer" class="dialog-footer">
  399. <el-button @click="dialogVisibleWeek = false">取 消</el-button>
  400. <el-button type="primary" @click="saveWeek">确 定</el-button>
  401. </span>
  402. </el-dialog>
  403. <el-dialog
  404. title="时间段选择"
  405. :visible.sync="dialogVisibleTime"
  406. width="700px"
  407. :before-close="handleCloseTime"
  408. >
  409. <div style="padding: 5px 0">
  410. <el-tabs v-model="activeTabName">
  411. <el-tab-pane label="逐个添加" name="first"></el-tab-pane>
  412. <el-tab-pane label="批量添加" name="second"></el-tab-pane>
  413. </el-tabs>
  414. </div>
  415. <div style="padding: 5px 0">
  416. 选择时段:
  417. <span v-if="activeTabName === 'first'">
  418. <el-time-picker style="width:130px" v-model="stime" format="HH:mm" value-format="HH:mm" size="small" key="first01" placeholder="请选择时间"></el-time-picker>
  419. <el-select style="width:80px" v-model="stype" placeholder="请选择" size="small">
  420. <el-option label="今日" :value="0"></el-option>
  421. <el-option label="其他" :value="1"></el-option>
  422. </el-select>
  423. <el-input v-if="stype == 1" @input="changeSday" type="number" v-model="sday" size="small" style="width: 70px;" placeholder="天数"></el-input> 天后
  424. <el-time-picker style="width:130px" v-model="etime" format="HH:mm" value-format="HH:mm" size="small" key="first02" placeholder="请选择时间"></el-time-picker>
  425. <el-button @click="addTime" size="small">添加</el-button>
  426. </span>
  427. <span v-if="activeTabName === 'second'">
  428. <el-time-picker
  429. style="width:290px"
  430. is-range
  431. v-model="setime"
  432. key="second01"
  433. format="HH:mm"
  434. value-format="HH:mm"
  435. size="small"
  436. range-separator="至"
  437. start-placeholder="开始时间"
  438. end-placeholder="结束时间"
  439. placeholder="选择时间范围"
  440. ></el-time-picker>
  441. 每隔
  442. <el-input type="number" v-model="snums" size="small" style="width: 70px;" placeholder="天数"></el-input> 小时执行一次
  443. <el-button @click="addBatchTime" size="small">添加</el-button>
  444. </span>
  445. </div>
  446. <div style="padding: 5px 0">
  447. 已选择时间段:
  448. <el-tag
  449. style="margin-right: 5px;margin-bottom: 5px"
  450. size="small"
  451. :key="index"
  452. v-for="(item,index) in selTimes"
  453. closable
  454. @close="handleCloseTimes(item)">
  455. {{item.stime}} ~ <span v-if="item.stype == 1">{{item.sday}}天后</span>{{item.etime}}
  456. </el-tag>
  457. </div>
  458. <span slot="footer" class="dialog-footer">
  459. <el-button @click="dialogVisibleTime = false">取 消</el-button>
  460. <el-button type="primary" @click="saveTime">确 定</el-button>
  461. </span>
  462. </el-dialog>
  463. </div>
  464. </div>
  465. </div>
  466. </div>
  467. {/block}
  468. {block name="script"}
  469. <script>
  470. var ads = {:json_encode($patrolForm)};
  471. var frs = [];
  472. var us = {:json_encode($user)};
  473. {empty name="info"}
  474. var info = null;
  475. {else /}
  476. var info = {:json_encode($info)};
  477. {/empty}
  478. localStorage.removeItem("selectids");
  479. var vm = new Vue({
  480. el: '#vue-plan',
  481. data: function() {
  482. return {
  483. title: '',
  484. dialogVisible: false,
  485. step: 0,
  486. date: '',
  487. tableData: [],
  488. selAddrForms: [], // 选择的地址表单
  489. addrs: ads,
  490. selAddrs:[], // 选择地址
  491. dialogVisibleAddr: false,
  492. addrkeyword: '',
  493. forms: frs,
  494. selForm: [],
  495. formkeyword: '',
  496. dialogVisibleForm: false,
  497. users: us, // 人员列表
  498. userIds:[], // 选择的人员
  499. dateTypes: [
  500. {id: 1,title: '天'},
  501. {id: 2,title: '周'},
  502. {id: 4,title: '月'},
  503. {id: 5,title: '循环周'},
  504. {id: 3,title: '自定义'},
  505. ],
  506. dateType: 1,
  507. dateFrom: '', // 自定义类型从哪天开始
  508. datePlay: 1,
  509. datePause: 1,
  510. dateWeeks: [], // 已选择的周
  511. dateTimes: [], // 已添加的时间段
  512. weeks: [
  513. {id:1,title:'周一',type: 'info'},
  514. {id:2,title:'周二',type: 'info'},
  515. {id:3,title:'周三',type: 'info'},
  516. {id:4,title:'周四',type: 'info'},
  517. {id:5,title:'周五',type: 'info'},
  518. {id:6,title:'周六',type: 'info'},
  519. {id:0,title:'周日',type: 'info'},
  520. ],
  521. selWeeks: [],
  522. dialogVisibleWeek: false,
  523. dialogVisibleTime: false,
  524. stime: '',
  525. etime: '',
  526. stype: 0,
  527. sday: 1,
  528. selTimes: [], // 弹框已选的时间段
  529. tasks: { // 任务
  530. days: [],
  531. list: [],
  532. },
  533. activeTabName: 'first',
  534. setime: '',
  535. snums: 1,
  536. inOrder: 0,
  537. lines: [],
  538. groups: []
  539. }
  540. },
  541. watch: {
  542. addrIds() { // 以保存的地址id
  543. console.log('tableData',this.tableData);
  544. let lines = [];
  545. if(this.tableData.length >= 2){
  546. for (let i in this.tableData){
  547. if(i < this.tableData.length - 1){
  548. lines.push({
  549. s: this.tableData[i].addrId,
  550. st: this.tableData[i].addrTitle,
  551. e: this.tableData[Number(i)+1].addrId,
  552. et: this.tableData[Number(i)+1].addrTitle,
  553. kd: 0,
  554. fd: 0,
  555. })
  556. }
  557. }
  558. }
  559. this.lines = JSON.parse(JSON.stringify(lines));
  560. console.log('lines',this.lines);
  561. },
  562. allgroups(){
  563. if(this.groups.length > 0){
  564. $('#groupbox').val(JSON.stringify(this.groups));
  565. }else{
  566. $('#groupbox').val('');
  567. }
  568. }
  569. },
  570. computed: {
  571. addrIds() { // 以保存的地址id
  572. let ids = [];
  573. this.tableData.forEach((item) => {
  574. ids.push(item.addrId);
  575. });
  576. return ids;
  577. },
  578. allgroups() {
  579. return JSON.parse(JSON.stringify(this.groups));
  580. }
  581. },
  582. created(){
  583. if(info){
  584. this.title = info.title;
  585. this.date = [info.start_time,info.end_time];
  586. this.groups = info.content.addrForms;
  587. this.userIds = info.content.userIds;
  588. this.dateType = info.content.dateType;
  589. this.dateForm = info.content.dateForm;
  590. this.datePlay = info.content.datePlay;
  591. this.datePause = info.content.datePause;
  592. this.dateWeeks = info.content.dateWeeks;
  593. this.dateTimes = info.content.dateTimes;
  594. this.datePause = info.content.datePause;
  595. this.datePause = info.content.datePause;
  596. this.lines = info.lines;
  597. this.inOrder = info.in_order;
  598. }
  599. },
  600. methods: {
  601. next() {
  602. if(this.step == 0){ // 检查必填项
  603. if(!this.title){
  604. this.$message.error('请输入任务名称');
  605. return false;
  606. }
  607. if(!this.date){
  608. this.$message.error('请选择任务时间');
  609. return false;
  610. }
  611. // if(this.tableData.length == 0){
  612. // this.$message.error('请选择任务地点');
  613. // return false;
  614. // }
  615. if(this.groups.length == 0){
  616. this.$message.error('未配置检查内容');
  617. return false;
  618. }
  619. let ff = false;
  620. this.groups.forEach((item) => {
  621. if(!item.title){
  622. this.$message.error('未输入检查内容');
  623. ff = true;
  624. return false;
  625. }
  626. if(item.forms.length == 0){
  627. this.$message.error('未选择检查项');
  628. ff = true;
  629. return false;
  630. }
  631. if(Number(item.type) > 0 && item.buss.length == 0){
  632. this.$message.error('未选择关联项');
  633. ff = true;
  634. return false;
  635. }
  636. });
  637. if(ff){
  638. return false;
  639. }
  640. } else if(this.step == 1){
  641. if(this.userIds.length <= 0){
  642. this.$message.error('未设置人员');
  643. return false;
  644. }
  645. if(this.dateType == 2 && this.dateWeeks.length <= 0){ // 周
  646. this.$message.error('未选择周');
  647. return false;
  648. }
  649. if(this.dateTimes.length <= 0){
  650. this.$message.error('未选择时间段');
  651. return false;
  652. }
  653. if(this.dateType == 3){ // 自定义
  654. if(!this.dateFrom){
  655. this.$message.error('未选择自定义开始日期');
  656. return false;
  657. }
  658. if(this.datePlay <= 0){
  659. this.$message.error('任务天数必须大于0');
  660. return false;
  661. }
  662. if(this.datePause < 0){
  663. this.$message.error('暂停天数必须大于等于0');
  664. return false;
  665. }
  666. }
  667. // 重新生成任务
  668. this.createClass();
  669. }
  670. if (this.step++ > 2) this.step = 0;
  671. },
  672. pre() {
  673. if (this.step-- < 0) this.step = 2;
  674. },
  675. handleSelectionChange(val){
  676. this.selAddrForms = val;
  677. console.log('selAddrForms',this.selAddrForms);
  678. },
  679. handleClose(){
  680. this.dialogVisibleAddr = false;
  681. },
  682. handleSelectionChangeAddr(val){
  683. this.selAddrs = val;
  684. },
  685. addGroup(){
  686. this.groups.push({
  687. title: '',
  688. forms: [],
  689. type: 0,
  690. buss: []
  691. });
  692. },
  693. selectAddr(){
  694. this.dialogVisibleAddr = true;
  695. this.addrkeyword = '';
  696. this.addrs = ads.filter((item) => {
  697. return !this.addrIds.includes(item.id);
  698. });
  699. this.selAddrs = [];
  700. },
  701. sortAddrs(){
  702. let ll = JSON.parse(JSON.stringify(this.tableData));
  703. ll.sort((a, b) => {
  704. return Number(a.sorts) > Number(b.sorts) ? 1 : -1;
  705. });
  706. console.log('ll',ll);
  707. this.tableData = [];
  708. this.$nextTick(() => {
  709. this.tableData = JSON.parse(JSON.stringify(ll));
  710. });
  711. },
  712. searchAddr(){
  713. this.addrs= [];
  714. this.$nextTick(() => {
  715. if(this.addrkeyword){
  716. this.addrs = ads.filter((item) => {
  717. return item.title.indexOf(this.addrkeyword) !== -1;
  718. });
  719. }else{
  720. this.addrs = ads;
  721. }
  722. });
  723. },
  724. saveAddr(){
  725. const tbs = this.tableData;
  726. this.selAddrs.forEach((item) => {
  727. if(!this.addrIds.includes(item.id)){
  728. tbs.push({
  729. 'addrId': item.id,
  730. 'addrTitle': item.title,
  731. // 'forms': [],
  732. 'sorts': 0
  733. });
  734. }
  735. });
  736. this.dialogVisibleAddr = false;
  737. this.$nextTick(() => {
  738. this.tableData = tbs;
  739. });
  740. },
  741. moveUp(idx,obj){
  742. if(idx > 0){
  743. let old = JSON.parse(JSON.stringify(this.tableData[idx]));
  744. let up = JSON.parse(JSON.stringify(this.tableData[idx - 1]));
  745. let tbs = this.tableData;
  746. this.tableData = [];
  747. this.$nextTick(() => {
  748. tbs[idx] = up;
  749. tbs[idx - 1] = old;
  750. this.tableData = tbs;
  751. })
  752. }
  753. },
  754. moveDown(idx,obj){ // 下移
  755. let length = this.tableData.length;
  756. if(idx < length - 1){
  757. let old = JSON.parse(JSON.stringify(this.tableData[idx]));
  758. let up = JSON.parse(JSON.stringify(this.tableData[idx + 1]));
  759. let tbs = this.tableData;
  760. this.tableData = [];
  761. this.$nextTick(() => {
  762. tbs[idx] = up;
  763. tbs[idx + 1] = old;
  764. this.tableData = tbs;
  765. })
  766. }
  767. },
  768. delAddrs(){ // 移除
  769. let sids = [];
  770. this.selAddrForms.forEach((item) => {
  771. sids.push(item.addrId);
  772. });
  773. if(sids.length == 0){
  774. this.$message.error('未选择地点');
  775. return false;
  776. }
  777. let tbs = this.tableData;
  778. this.tableData = [];
  779. this.$nextTick(() => {
  780. this.tableData = tbs.filter((item) => {
  781. return !sids.includes(item.addrId);
  782. });
  783. this.selAddrForms = [];
  784. });
  785. },
  786. handleCurrentChange(val){ // 选中检查内容
  787. this.selForm = val;
  788. },
  789. handleCloseForm(){
  790. this.dialogVisibleForm = false;
  791. },
  792. searchForm(){
  793. this.forms= [];
  794. this.$nextTick(() => {
  795. if(this.formkeyword){
  796. this.forms = frs.filter((item) => {
  797. return item.title.indexOf(this.formkeyword) !== -1;
  798. });
  799. }else{
  800. this.forms = frs;
  801. }
  802. });
  803. },
  804. saveForm(){
  805. const tbs = this.tableData;
  806. this.tableData = [];
  807. let sids = [];
  808. this.selAddrForms.forEach((item) => {
  809. sids.push(item.addrId);
  810. });
  811. tbs.forEach((item) => {
  812. if(sids.includes(item.addrId)){
  813. // item.formId = this.selForm?this.selForm.id:0;
  814. // item.formTitle = this.selForm?this.selForm.title:'';
  815. const ffs = [];
  816. this.selForm.forEach((fitem) => {
  817. ffs.push({
  818. id: fitem.id,
  819. title: fitem.title
  820. });
  821. });
  822. item.forms = JSON.parse(JSON.stringify(ffs));
  823. }
  824. });
  825. this.dialogVisibleForm = false;
  826. this.$nextTick(() => {
  827. this.tableData = tbs;
  828. this.selAddrForms = [];
  829. });
  830. },
  831. selectForm(idx,obj){
  832. console.log(idx,obj,this.groups);
  833. this.groups.forEach((item,index) => {
  834. if(Number(idx) == Number(index)){
  835. item.forms = obj;
  836. console.log(idx,index);
  837. }
  838. });
  839. let ids = [];
  840. obj.forEach((item) => {
  841. ids.push(item.id.toString());
  842. });
  843. if(ids.length > 0){
  844. $('#formsbtn'+idx).attr('data-ids',JSON.stringify(ids));
  845. }else{
  846. $('#formsbtn'+idx).attr('data-ids','');
  847. }
  848. localStorage.removeItem("selectids");
  849. },
  850. selectBuss(idx,obj){
  851. console.log(idx,obj,this.groups);
  852. this.groups.forEach((item,index) => {
  853. if(Number(idx) == Number(index)){
  854. item.buss = obj;
  855. console.log(idx,index,item);
  856. }
  857. });
  858. let ids = [];
  859. obj.forEach((item) => {
  860. ids.push(item.id.toString());
  861. });
  862. if(ids.length > 0){
  863. $('#bussbtn'+idx).attr('data-ids',JSON.stringify(ids));
  864. }else{
  865. $('#bussbtn'+idx).attr('data-ids','');
  866. }
  867. localStorage.removeItem("selectids");
  868. },
  869. selectFormOld(){
  870. let sids = [];
  871. this.selAddrForms.forEach((item) => {
  872. sids.push(item.addrId);
  873. });
  874. if(sids.length == 0){
  875. this.$message.error('未选择地点');
  876. return false;
  877. }
  878. console.log('ss',this.selAddrForms);
  879. this.dialogVisibleForm = true;
  880. this.forms = frs;
  881. this.selForm = null;
  882. },
  883. changeType(idx,obj){
  884. let url = "{:url('QualityPlan/buslist',[],false,false)}/idx/"+idx+"/type/"+obj.type;
  885. console.log(obj);
  886. this.groups.forEach((item,index) => {
  887. if(Number(idx) == Number(index)){
  888. item.buss = [];
  889. }
  890. });
  891. $('#bussbtn'+idx).attr('data-ids','');
  892. $('#bussbtn'+idx).attr('url',url);
  893. },
  894. delGroup(idx){
  895. let ggs = JSON.parse(JSON.stringify(this.groups));
  896. let ng = [];
  897. ggs.forEach((item,index) => {
  898. if(Number(idx) != Number(index)){
  899. ng.push(item);
  900. }
  901. });
  902. this.groups = JSON.parse(JSON.stringify(ng));
  903. },
  904. delForms(idx,fidx){
  905. console.log(idx,fidx);
  906. let ggs = JSON.parse(JSON.stringify(this.groups));
  907. let ng = [];
  908. ggs.forEach((item,index) => {
  909. if(Number(idx) == Number(index)){
  910. let fggs = JSON.parse(JSON.stringify(item.forms));
  911. let fng = [];
  912. fggs.forEach((item2,index2) => {
  913. if(Number(fidx) != Number(item2.id)){
  914. fng.push(item2);
  915. }
  916. });
  917. item.forms = JSON.parse(JSON.stringify(fng));
  918. }
  919. ng.push(item);
  920. });
  921. this.groups = JSON.parse(JSON.stringify(ng));
  922. },
  923. delBuss(idx,bidx){
  924. console.log(idx,bidx);
  925. let ggs = JSON.parse(JSON.stringify(this.groups));
  926. let ng = [];
  927. ggs.forEach((item,index) => {
  928. if(Number(idx) == Number(index)){
  929. let fggs = JSON.parse(JSON.stringify(item.buss));
  930. let fng = [];
  931. fggs.forEach((item2,index2) => {
  932. if(Number(bidx) != Number(item2.id)){
  933. fng.push(item2);
  934. }
  935. });
  936. item.buss = JSON.parse(JSON.stringify(fng));
  937. }
  938. ng.push(item);
  939. });
  940. this.groups = JSON.parse(JSON.stringify(ng));
  941. },
  942. handleCloseWeek(){
  943. this.dialogVisibleWeek = false;
  944. },
  945. saveWeek(){
  946. let ll = [];
  947. this.weeks.forEach((item) => {
  948. if(this.selWeeks.includes(item.id)){
  949. ll.push({
  950. id: item.id,
  951. title: item.title,
  952. type: 'primary'
  953. })
  954. }
  955. });
  956. this.dateWeeks = ll;
  957. this.dialogVisibleWeek = false;
  958. },
  959. handleWeek(obj){
  960. console.log(obj);
  961. if(this.selWeeks.includes(obj.id)){
  962. this.selWeeks = this.selWeeks.filter((item) => {
  963. return item !== obj.id;
  964. });
  965. }else{
  966. this.selWeeks.push(obj.id);
  967. }
  968. this.weeks.forEach((item) => {
  969. if(this.selWeeks.includes(item.id)){
  970. item.type = 'primary';
  971. }else{
  972. item.type = 'info';
  973. }
  974. });
  975. },
  976. selectWeek(){
  977. this.selWeeks = [];
  978. this.dateWeeks.forEach((item) => {
  979. this.selWeeks.push(item.id);
  980. });
  981. this.weeks.forEach((item) => {
  982. if(this.selWeeks.includes(item.id)){
  983. item.type = 'primary';
  984. }else{
  985. item.type = 'info';
  986. }
  987. });
  988. this.dialogVisibleWeek = true;
  989. },
  990. handleCloseTime(){
  991. this.dialogVisibleTime = false;
  992. },
  993. addTime(){
  994. if(!this.stime || !this.etime){
  995. this.$message.error('请选择时间段');
  996. return false;
  997. }
  998. if(this.stype == 0 && this.stime >= this.etime){
  999. this.$message.error('时间段错误');
  1000. return false;
  1001. }
  1002. if(this.stype == 1 && this.sday < 1){
  1003. this.$message.error('天数必须大于0');
  1004. return false;
  1005. }
  1006. // 检查时间段是否重复
  1007. let ff = false;
  1008. this.selTimes.forEach((item) => {
  1009. if(item.stype == this.stype &&item.sday == this.sday && item.stime == this.stime && item.etime == this.etime){
  1010. ff = true;
  1011. }
  1012. });
  1013. if(ff){
  1014. this.$message.error('该时间段已存在');
  1015. return false;
  1016. }
  1017. this.selTimes.push({
  1018. stime: this.stime,
  1019. etime: this.etime,
  1020. stype: this.stype,
  1021. sday: this.sday
  1022. })
  1023. },
  1024. addBatchTime(){
  1025. if(!this.setime || this.setime.length !== 2){
  1026. this.$message.error('请选择时间段');
  1027. return false;
  1028. }
  1029. if(this.snums <= 0){
  1030. this.$message.error('请输入间隔小时数');
  1031. return false;
  1032. }
  1033. // let min = 0;
  1034. // let max = 23*50 + 59;
  1035. let st = this.timeToNum(this.setime[0]);
  1036. let et = this.timeToNum(this.setime[1]);
  1037. let times = [];
  1038. let start = this.timeToNum(this.setime[0]);
  1039. let end = this.timeToNum(this.setime[0]);
  1040. let i = 1;
  1041. while (true){
  1042. end = this.timeToNum(this.setime[0]) + 60*this.snums*i;
  1043. let jg = et - start;
  1044. if(end > et && jg < 10){
  1045. break;
  1046. }else if(end > et && jg > 10){
  1047. end = et;
  1048. }
  1049. this.stime = this.numToTime(start);
  1050. this.etime = this.numToTime(end);
  1051. this.stype = 0;
  1052. this.sday = 0;
  1053. // 检查时间段是否重复
  1054. let ff = false;
  1055. this.selTimes.forEach((item) => {
  1056. if(item.stype == this.stype &&item.sday == this.sday && item.stime == this.stime && item.etime == this.etime){
  1057. ff = true;
  1058. }
  1059. });
  1060. if(ff){
  1061. this.$message.error('该时间段已存在');
  1062. return false;
  1063. }
  1064. this.selTimes.push({
  1065. stime: this.stime,
  1066. etime: this.etime,
  1067. stype: this.stype,
  1068. sday: this.sday
  1069. });
  1070. start = this.timeToNum(this.setime[0]) + 60*this.snums*i;
  1071. i++;
  1072. }
  1073. console.log('this.selTimes',this.selTimes);
  1074. },
  1075. timeToNum(time){ // time格式12:30
  1076. let ts = time.split(':');
  1077. if(ts.length !== 2){
  1078. return 0;
  1079. }
  1080. return Number(ts[0])*60 + Number(ts[1]);
  1081. },
  1082. numToTime(num){ // 数字转时间
  1083. let h = parseInt(num/60);
  1084. let m = num - h*60;
  1085. let str = '';
  1086. if(h < 10){
  1087. str += '0' + h + ':';
  1088. }else{
  1089. str += h + ':';
  1090. }
  1091. if(m < 10){
  1092. str += '0' + m;
  1093. }else{
  1094. str += m;
  1095. }
  1096. return str;
  1097. },
  1098. saveTime(){
  1099. this.dateTimes = JSON.parse(JSON.stringify(this.selTimes));
  1100. this.handleCloseTime();
  1101. },
  1102. handleCloseTimes(obj){
  1103. this.selTimes = this.selTimes.filter((item) => {
  1104. return item.stime != obj.stime || item.etime != obj.etime || item.stype != obj.stype || item.sday != obj.sday;
  1105. })
  1106. },
  1107. selectTime(){
  1108. this.dialogVisibleTime = true;
  1109. this.selTimes = JSON.parse(JSON.stringify(this.dateTimes));
  1110. this.stime = '';
  1111. this.etime = '';
  1112. this.stype = 0;
  1113. this.sday = 1;
  1114. },
  1115. changeSday(){
  1116. if (this.sday) {
  1117. // 限制整数
  1118. this.sday = this.sday.replace(/[^\d]/g, '');
  1119. }
  1120. },
  1121. createClass(){
  1122. if(this.userIds.length <= 0){
  1123. this.$message.error('未设置人员');
  1124. return false;
  1125. }
  1126. if(this.dateType == 2 && this.dateWeeks.length <= 0){ // 周
  1127. this.$message.error('未选择周');
  1128. return false;
  1129. }
  1130. if(this.dateTimes.length <= 0){
  1131. this.$message.error('未选择时间段');
  1132. return false;
  1133. }
  1134. if(this.dateType == 3){ // 自定义
  1135. if(!this.dateFrom){
  1136. this.$message.error('未选择自定义开始日期');
  1137. return false;
  1138. }
  1139. if(this.datePlay <= 0){
  1140. this.$message.error('任务天数必须大于0');
  1141. return false;
  1142. }
  1143. if(this.datePause < 0){
  1144. this.$message.error('暂停天数必须大于等于0');
  1145. return false;
  1146. }
  1147. }
  1148. let days = this.formatDays();
  1149. this.formatTasks(days);
  1150. },
  1151. formatTasks(days){
  1152. this.tasks = {
  1153. days: days,
  1154. list: [],
  1155. };
  1156. let list = [];
  1157. this.dateTimes.forEach((item) => {
  1158. let ts = [];
  1159. days.forEach((item2) => {
  1160. ts.push({
  1161. day: item2,
  1162. userIds: this.userIds,
  1163. userNames: this.getUserNames(),
  1164. });
  1165. });
  1166. list.push({
  1167. time: item,
  1168. list: ts,
  1169. })
  1170. });
  1171. this.tasks = {
  1172. days: days,
  1173. list: list,
  1174. };
  1175. console.log('tasks',this.tasks);
  1176. },
  1177. delDay(day){ // 删除列
  1178. let ts = JSON.parse(JSON.stringify(this.tasks));
  1179. this.tasks = null;
  1180. let days = ts.days.filter((item) => {
  1181. return item != day;
  1182. });
  1183. this.formatTasks(days);
  1184. },
  1185. delTimes(obj){ // 删除行
  1186. let days = JSON.parse(JSON.stringify(this.tasks.days));
  1187. this.tasks = null;
  1188. this.dateTimes = this.dateTimes.filter((item) => {
  1189. return item.stime != obj.stime || item.etime != obj.etime || item.stype != obj.stype || item.sday != obj.sday;
  1190. });
  1191. this.formatTasks(days);
  1192. },
  1193. saveSubmit(){ // 表单提交
  1194. if(this.tasks.days.length <= 0||this.tasks.list.length <= 0){
  1195. this.$message.error('未设置任务');
  1196. return false;
  1197. }
  1198. let content = {
  1199. addrForms: this.groups,
  1200. userIds: this.userIds,
  1201. dateType: this.dateType,
  1202. dateFrom: this.dateType == 3?this.dateFrom:'',
  1203. datePlay: this.dateType == 3?this.datePlay:0,
  1204. datePause: this.dateType == 3?this.datePause:0,
  1205. dateWeeks: this.dateType == 2?this.dateWeeks:[],
  1206. dateTimes: this.dateTimes,
  1207. tasks: this.tasks,
  1208. };
  1209. let json = {
  1210. title: this.title,
  1211. start_time: this.date[0],
  1212. end_time: this.date[1],
  1213. content: JSON.stringify(content),
  1214. // in_order: this.inOrder,
  1215. // lines: this.lines.length > 0?JSON.stringify(this.lines):''
  1216. };
  1217. let that = this;
  1218. $('#saveSubmit').attr("disabled", true).html('保 存 中');
  1219. $.ajax({
  1220. url: "{:url('QualityPlan/add')}",
  1221. type: 'POST',
  1222. data: json,
  1223. success: function(ret){
  1224. if(ret.code == 1){
  1225. that.$message.success('操作成功');
  1226. parent.layer.closeAll();
  1227. // window.location.href = "{:url('index')}";
  1228. }else{
  1229. that.$message.error(ret.msg);
  1230. }
  1231. $('#saveSubmit').attr("disabled", false).html('保 存');
  1232. },
  1233. error: function (){
  1234. that.$message.error('请求失败');
  1235. $('#saveSubmit').attr("disabled", false).html('保 存');
  1236. }
  1237. });
  1238. },
  1239. getUserNames(){
  1240. let ns = [];
  1241. this.userIds.forEach((item) => {
  1242. this.users.forEach((item2) => {
  1243. if(item2.id == item){
  1244. ns.push(item2.title);
  1245. }
  1246. });
  1247. });
  1248. return ns.join(',');
  1249. },
  1250. formatDays(){ // 格式化任务日期
  1251. let days = this.getDateAll(this.date[0],this.date[1]);
  1252. let nday = [];
  1253. let ws = [];
  1254. this.dateWeeks.forEach((item) => {
  1255. ws.push(item.id);
  1256. });
  1257. let i = 0;
  1258. let j = 0;
  1259. if(this.dateType==4){
  1260. days = this.dateCutByMonth(this.date[0],this.date[1]);
  1261. }
  1262. if(this.dateType==5){
  1263. days = this.addWeeks(this.date[0],this.date[1]);
  1264. }
  1265. days.forEach((item) => {
  1266. if(this.dateType == 1){ // 日
  1267. nday.push(item);
  1268. }else if(this.dateType == 2){ // 周
  1269. let ww = this.getWeekByDay(item);
  1270. if(ws.includes(ww)){
  1271. nday.push(item);
  1272. }
  1273. }else if(this.dateType == 3){ // 自定义
  1274. if(this.dateFrom <= item){
  1275. if(i + j < this.datePlay){
  1276. nday.push(item);
  1277. i++;
  1278. }else if((i + j) >= this.datePlay && (i+j) < this.datePause){
  1279. j++;
  1280. }else{
  1281. i = 0;
  1282. j = 0;
  1283. }
  1284. }
  1285. }else if(this.dateType == 4 || this.dateType == 5){ // 月
  1286. nday.push(item);
  1287. }
  1288. });
  1289. return nday;
  1290. },
  1291. changePlay(){
  1292. if (this.datePlay) {
  1293. // 限制整数
  1294. this.datePlay = this.datePlay.replace(/[^\d]/g, '');
  1295. }
  1296. },
  1297. changePause(){
  1298. if (this.datePause) {
  1299. // 限制整数
  1300. this.datePause = this.datePause.replace(/[^\d]/g, '');
  1301. }
  1302. },
  1303. getDateAll(starDay, endDay) { // 获取两个时间段的所有日期
  1304. var arr = [];
  1305. var dates = [];
  1306. // 设置两个日期UTC时间
  1307. var db = new Date(starDay);
  1308. var de = new Date(endDay);
  1309. // 获取两个日期GTM时间
  1310. var s = db.getTime() - 24 * 60 * 60 * 1000;
  1311. var d = de.getTime() - 24 * 60 * 60 * 1000;
  1312. // 获取到两个日期之间的每一天的毫秒数
  1313. for (var i = s; i <= d; ) {
  1314. i = i + 24 * 60 * 60 * 1000;
  1315. arr.push(parseInt(i));
  1316. }
  1317. // 获取每一天的时间 YY-MM-DD
  1318. for (var j in arr) {
  1319. var time = new Date(arr[j]);
  1320. var year = time.getFullYear(time);
  1321. var mouth =
  1322. time.getMonth() + 1 >= 10
  1323. ? time.getMonth() + 1
  1324. : "0" + (time.getMonth() + 1);
  1325. var day =
  1326. time.getDate() >= 10
  1327. ? time.getDate()
  1328. : "0" + time.getDate();
  1329. var YYMMDD = year + "-" + mouth + "-" + day;
  1330. dates.push(YYMMDD);
  1331. }
  1332. return dates;
  1333. },
  1334. getWeekByDay(dateString,t=0) { // 获取某天是周几
  1335. var dateArray = dateString.split("-");
  1336. date = new Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
  1337. if(t == 1){
  1338. return "周" + "日一二三四五六".charAt(date.getDay());
  1339. }else{
  1340. return date.getDay();
  1341. }
  1342. },
  1343. dateCutByMonth(beginDate, endDate) {
  1344. //分割好的数组
  1345. var dateCutList = new Array();
  1346. var b_date = new Date(beginDate);
  1347. var e_date = new Date(endDate);
  1348. //获取各个的年份
  1349. var b_year = parseInt(b_date.getFullYear());
  1350. var e_year = parseInt(e_date.getFullYear());
  1351. //获取各个的月份
  1352. var b_month = parseInt(b_date.getMonth()) + 1;
  1353. var e_month = parseInt(e_date.getMonth()) + 1;
  1354. //获取日期之间想差的月数;
  1355. var month_list = this.monthList();
  1356. //按月份分割日期
  1357. if(month_list.length==1){
  1358. dateCutList.push(beginDate+'~'+endDate);
  1359. }else {
  1360. for (var i = 0; i < month_list.length; i++) {
  1361. //当前月开始日期:第一天
  1362. var i_b_date = new Date(month_list[i]);
  1363. i_b_date.setDate(1);
  1364. //当前月最后一天
  1365. var i_e_date = new Date(month_list[i]);
  1366. i_e_date.setMonth(i_e_date.getMonth() + 1);
  1367. i_e_date.setDate(1);
  1368. i_e_date.setDate(i_e_date.getDate() - 1);
  1369. //第一次循环:开始月份
  1370. if (i == 0) {
  1371. var i_e_ymd = this.parseTime(i_e_date).split(" ")[0];
  1372. dateCutList.push(beginDate+'~'+i_e_ymd);
  1373. //除第一次和最后一次循环:中间月份
  1374. } else if (i != 0 && i != month_list.length - 1) {
  1375. var i_b_ymd = this.parseTime(i_b_date).split(" ")[0];
  1376. var i_e_ymd = this.parseTime(i_e_date).split(" ")[0];
  1377. dateCutList.push(i_b_ymd+'~'+i_e_ymd);
  1378. // //最后一次循环:结束月份
  1379. } else if (i == month_list.length - 1) {
  1380. var i_b_ymd = this.parseTime(i_b_date).split(" ")[0];
  1381. dateCutList.push(i_b_ymd+'~'+endDate);
  1382. }
  1383. }
  1384. }
  1385. return dateCutList;
  1386. },
  1387. monthList() {
  1388. //相差的月份总数
  1389. var result = new Array();
  1390. var b_date = new Date(this.date[0]);
  1391. var e_date = new Date(this.date[1]);
  1392. //获取各个的年份
  1393. var b_year = parseInt(b_date.getFullYear());
  1394. var e_year = parseInt(e_date.getFullYear());
  1395. //获取各个的月份
  1396. var b_month = parseInt(b_date.getMonth()) + 1;
  1397. var e_month = parseInt(e_date.getMonth()) + 1;
  1398. var b = new Date(b_year, b_month - 1, 1);
  1399. var e = new Date(e_year, e_month - 1, 1);
  1400. while (b < e) {
  1401. result.push(b.getFullYear() + "-" + (b.getMonth() + 1));
  1402. b.setMonth(b.getMonth() + 1);
  1403. }
  1404. result.push(e_year + "-" + e_month);
  1405. return result;
  1406. },
  1407. parseTime(time, pattern) {
  1408. if (arguments.length === 0 || !time) {
  1409. return null
  1410. }
  1411. const format = pattern || '{y}-{m}-{d} {h}:{i}:{s}'
  1412. let date
  1413. if (typeof time === 'object') {
  1414. date = time
  1415. } else {
  1416. if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
  1417. time = parseInt(time)
  1418. } else if (typeof time === 'string') {
  1419. time = time.replace(new RegExp(/-/gm), '/').replace('T', ' ').replace(new RegExp(/\.[\d]{3}/gm),'');
  1420. }
  1421. if ((typeof time === 'number') && (time.toString().length === 10)) {
  1422. time = time * 1000
  1423. }
  1424. date = new Date(time)
  1425. }
  1426. const formatObj = {
  1427. y: date.getFullYear(),
  1428. m: date.getMonth() + 1,
  1429. d: date.getDate(),
  1430. h: date.getHours(),
  1431. i: date.getMinutes(),
  1432. s: date.getSeconds(),
  1433. a: date.getDay()
  1434. }
  1435. const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
  1436. let value = formatObj[key]
  1437. // Note: getDay() returns 0 on Sunday
  1438. if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value] }
  1439. if (result.length > 0 && value < 10) {
  1440. value = '0' + value
  1441. }
  1442. return value || 0
  1443. })
  1444. return time_str
  1445. },
  1446. addWeeks(start,end){
  1447. let dateArr = []
  1448. let startArr = start.split('-')
  1449. let endArr = end.split('-')
  1450. let db = new Date()
  1451. db.setUTCFullYear(startArr[0], startArr[1] - 1, startArr[2])
  1452. let de = new Date()
  1453. de.setUTCFullYear(endArr[0], endArr[1] - 1, endArr[2])
  1454. let unixDb = db.getTime()
  1455. let unixDe = de.getTime()
  1456. let stamp
  1457. const oneDay = 24 * 60 * 60 * 1000;
  1458. var i=0;
  1459. var s = start;
  1460. var e = end;
  1461. var wkNum = (unixDe-unixDb)/(7*24 * 60 * 60 * 1000);
  1462. var wkNum = Math.floor(wkNum);
  1463. console.log(wkNum);
  1464. console.log(121212);
  1465. for (stamp = unixDb; stamp <= unixDe;) {
  1466. let curDay = new Date(parseInt(stamp))
  1467. if(curDay.getDay()==0 && i<=wkNum){
  1468. dateArr.push(s+'~'+this.formatTime(curDay))
  1469. // dateArr.push(this.formatTime(curDay))
  1470. cc = curDay.getTime()+24 * 60 * 60 * 1000;
  1471. let c1 = new Date(parseInt(cc));
  1472. s=this.formatTime(c1);
  1473. i++;
  1474. } else{
  1475. if(i===wkNum){
  1476. i++;
  1477. dateArr.push(s+'~'+e)
  1478. }
  1479. }
  1480. stamp = stamp + oneDay
  1481. }
  1482. return dateArr
  1483. },
  1484. formatTime(time) {
  1485. let ymd = ''
  1486. let mouth = (time.getMonth() + 1) >= 10 ? (time.getMonth() + 1) : ('0' + (time.getMonth() + 1))
  1487. let day = time.getDate() >= 10 ? time.getDate() : ('0' + time.getDate())
  1488. ymd += time.getFullYear() + '-' // 获取年份。
  1489. ymd += mouth + '-' // 获取月份。
  1490. ymd += day // 获取日。
  1491. return ymd // 返回日期。
  1492. }
  1493. }
  1494. });
  1495. function selectBuss(_self) {
  1496. let ids = $(_self).attr('data-ids');
  1497. if(ids){
  1498. localStorage.setItem("selectids", ids);
  1499. }else{
  1500. localStorage.removeItem("selectids");
  1501. }
  1502. let url = $(_self).attr('url');
  1503. if(!url){
  1504. layer.msg('请选择关联业务');
  1505. return false;
  1506. }
  1507. layer_open(_self,0);
  1508. }
  1509. function selectForms(_self) {
  1510. let ids = $(_self).attr('data-ids');
  1511. if(ids){
  1512. localStorage.setItem("selectids", ids);
  1513. }else{
  1514. localStorage.removeItem("selectids");
  1515. }
  1516. layer_open(_self,0);
  1517. }
  1518. </script>
  1519. {/block}