c28472fa9da5b0772ffa1ab9ba94a91c9ddddc72.svn-base 106 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373
  1. <template>
  2. <div class="app-container">
  3. <!-- 配方模板表 -->
  4. <div ref="template" class="template">
  5. <p class="recipeTemplate" />
  6. <div class="operation">
  7. <el-button class="success" @click="handleCreate">新增</el-button>
  8. <el-button class="danger" @click="handleDelete">删除</el-button>
  9. <el-button class="warning" @click="handleCopy">复制</el-button>
  10. <el-button class="success" @click="handleRecipeRecord">配方记录</el-button>
  11. <el-button class="success" @click="handleHistory">生成历史</el-button>
  12. <el-upload style="float: right;margin-right: 75px;" :headers="headers" :data="uploadData" :action="uploadExcelUrl" :show-file-list="false" :before-upload="beforeImport" :on-success="handleImportSuccess">
  13. <el-button class="import" style="float: right;">导入</el-button>
  14. </el-upload>
  15. <el-dropdown style="float: right;margin-right: 10px;">
  16. <el-button class="export">导出</el-button>
  17. <el-dropdown-menu slot="dropdown">
  18. <el-dropdown-item @click.native="handleExport(1)">导出模板</el-dropdown-item>
  19. <el-dropdown-item @click.native="handleExport(2)">导出数据</el-dropdown-item>
  20. </el-dropdown-menu>
  21. </el-dropdown>
  22. </div>
  23. <div class="search">
  24. <el-select v-model="table.getdataListParm.parammaps.ccname" filterable placeholder="牲畜类别" class="filter-item" clearable>
  25. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  26. </el-select>
  27. <el-select v-model="table.getdataListParm.parammaps.fttype" filterable placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  28. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  29. </el-select>
  30. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  31. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  32. </el-select>
  33. <div ref="selectInput" class="filter-item selectInput">
  34. <el-input type="text" placeholder="请点击选择搜索条件" class="Input" />
  35. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  36. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  37. <ul v-if="arrowUp" class="selectUl">
  38. <li><a>配方名称</a><el-input v-model="table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  39. <li><a>备注</a><el-input v-model="table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  40. <li><a>来源</a><el-input v-model="table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  41. <li>
  42. <div style="float: right;">
  43. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  44. <el-button class="miniPrimary" @click="handleSearch">搜索</el-button>
  45. </div>
  46. </li>
  47. </ul>
  48. </div>
  49. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  50. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  51. </div>
  52. <div class="table">
  53. <el-table
  54. :key="table.tableKey"
  55. v-loading="table.listLoading"
  56. element-loading-text="给我一点时间"
  57. :data="table.list"
  58. border
  59. fit
  60. highlight-current-row
  61. style="width: 98%;"
  62. :row-style="rowStyle"
  63. :cell-style="cellStyle"
  64. class="elTable table-fixed"
  65. @row-click="tableRowClick"
  66. @selection-change="handleSelectionChange"
  67. >
  68. <el-table-column type="selection" align="center" width="50" />
  69. <el-table-column label="序号" align="center" type="index" width="50px">
  70. <template slot-scope="scope">
  71. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="配方名称" min-width="130px" align="center">
  75. <template slot-scope="scope">
  76. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  77. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="配方颜色" min-width="130px" align="center">
  81. <template slot-scope="scope">
  82. <el-color-picker v-model="scope.row.tcolor" size="mini" :disabled="scope.row.NoEdit" style="margin:10px 0;" />
  83. </template>
  84. </el-table-column>
  85. <el-table-column label="牲畜类别" min-width="150px" align="center">
  86. <template slot-scope="scope">
  87. <span v-if="scope.row.NoEdit">{{ scope.row.ccname }}</span>
  88. <el-select v-if="scope.row.Edit" v-model="scope.row.ccid" filterable placeholder="牲畜类别" class="filter-item" style="width:95%;padding:10px 0;" @change="changeLivestockType">
  89. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  90. </el-select>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="配方类型" min-width="150px" align="center">
  94. <template slot-scope="scope">
  95. <span v-if="scope.row.NoEdit">{{ scope.row.fttype }}</span>
  96. <el-select v-if="scope.row.Edit && scope.row.isCreate == true" v-model="scope.row.fttypeid" filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  97. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  98. </el-select>
  99. <el-select v-if="scope.row.Edit && scope.row.isUpdateSave == true" v-model="scope.row.fttypeid" disabled filterable placeholder="配方类型" class="filter-item" style="width:95%;padding:10px 0;" @change="changeFormulaType">
  100. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.value" />
  101. </el-select>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="来源" min-width="110px" align="center">
  105. <template slot-scope="scope">
  106. <span>{{ scope.row.source }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column label="备注" min-width="110px" align="center">
  110. <template slot-scope="scope">
  111. <span v-if="scope.row.NoEdit">{{ scope.row.remark }}</span>
  112. <el-input v-if="scope.row.Edit" v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" style="width:95%;padding:10px 0;" />
  113. </template>
  114. </el-table-column>
  115. <el-table-column label="是否启用" min-width="110px" align="center">
  116. <template slot-scope="scope">
  117. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  121. <template slot-scope="{row}">
  122. <!-- 新增 -->
  123. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  124. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  125. <!-- 编辑 -->
  126. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  127. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  128. <!-- 编辑保存 -->
  129. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  130. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  131. </template>
  132. </el-table-column>
  133. </el-table>
  134. </div>
  135. </div>
  136. <!-- 配方详情表 -->
  137. <div v-if="isDetail" ref="detail" class="detail" style="margin-top: 30px;">
  138. <p class="recipeDetail" />
  139. <div class="operation">
  140. <el-button class="success" @click="handleCreate2">新增</el-button>
  141. <el-button class="danger" @click="handleDelete2">删除</el-button>
  142. <el-button class="success" @click="handleSyntheticPremix">合成预混料</el-button>
  143. <div ref="selectInput2" class="filter-item selectInput" style="margin: 0 10px;">
  144. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  145. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  146. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  147. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  148. <li>
  149. <a style="width: 130px;">饲料名称</a>
  150. <el-select v-model="table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  151. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  152. </el-select>
  153. </li>
  154. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  155. <li><a style="width: 130px;">重量</a><el-input v-model="table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  156. <li>
  157. <a style="width: 130px;">搅拌延时</a>
  158. <el-select v-model="table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;" clearable>
  159. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  160. </el-select>
  161. </li>
  162. <li>
  163. <a style="width: 130px;">是否锁定牛头数比例</a>
  164. <el-select v-model="table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;" clearable>
  165. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  166. </el-select>
  167. </li>
  168. <li><a style="width: 130px;">顺序</a><el-input v-model="table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  169. <li>
  170. <div style="float: right;">
  171. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  172. <el-button class="miniSuccess" @click="handleSearch2">搜索</el-button>
  173. </div>
  174. </li>
  175. </ul>
  176. </div>
  177. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  178. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  179. </div>
  180. <div class="table2" style="min-height: 400px;">
  181. <el-table
  182. id="table2"
  183. ref="table2"
  184. :key="table2.tableKey"
  185. v-loading="table2.listLoading"
  186. element-loading-text="给我一点时间"
  187. :data="table2.list"
  188. border
  189. fit
  190. highlight-current-row
  191. style="width: 98%;"
  192. :row-style="rowStyle"
  193. :cell-style="cellStyle"
  194. class="elTable table-fixed"
  195. row-key="id"
  196. show-summary
  197. @selection-change="handleSelectionChange2"
  198. >
  199. <el-table-column type="selection" width="60" />
  200. <el-table-column label="序号" align="center" type="index" width="50px" />
  201. <el-table-column label="饲料组" min-width="110px" align="center">
  202. <template slot-scope="scope">
  203. <span v-if="scope.row.groupNoEdit">{{ scope.row.feedgroup }}</span>
  204. <el-input v-if="scope.row.groupEdit" v-model="scope.row.feedgroup" :disabled="scope.row.isGroupDisabled" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" />
  205. </template>
  206. </el-table-column>
  207. <el-table-column label="饲料名称" min-width="130px" align="center">
  208. <template slot-scope="scope">
  209. <span v-if="scope.row.NoEdit">{{ scope.row.fname }}</span>
  210. <el-select v-if="scope.row.Edit" v-model="scope.row.fid" filterable placeholder="" class="filter-item" style="width:95%;padding:10px 0;" @change="(value)=> {changeFname(value, scope.row)}">
  211. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.id" />
  212. </el-select>
  213. </template>
  214. </el-table-column>
  215. <el-table-column label="重量(KG)" prop="fweight" min-width="100px" align="center">
  216. <template slot-scope="scope">
  217. <span v-if="scope.row.NoEdit">{{ scope.row.fweight }}</span>
  218. <el-input v-if="scope.row.Edit" v-model="scope.row.fweight" placeholder="重量" step="0.01" type="number" style="width:95%;padding:10px 0;" />
  219. </template>
  220. </el-table-column>
  221. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  222. <template slot-scope="scope">
  223. <span v-if="scope.row.NoEdit">{{ scope.row.autosecond }}</span>
  224. <el-select v-if="scope.row.Edit" v-model="scope.row.autosecond" filterable placeholder="搅拌延时" class="filter-item" style="width:95%;padding:10px 0;">
  225. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.id" />
  226. </el-select>
  227. </template>
  228. </el-table-column>
  229. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="110px" align="center">
  230. <template slot-scope="scope">
  231. <span v-if="scope.row.NoEdit && scope.row.islockcount == '0'">否</span>
  232. <span v-if="scope.row.NoEdit && scope.row.islockcount == '1'">是</span>
  233. <el-select v-if="scope.row.Edit" v-model="scope.row.islockcount" placeholder="" class="filter-item" style="width:95%;padding:10px 0;">
  234. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  235. </el-select>
  236. </template>
  237. </el-table-column>
  238. <el-table-column label="顺序" min-width="100px" align="center">
  239. <template slot-scope="scope">
  240. <span v-if="scope.row.NoEdit">{{ scope.row.sort }}</span>
  241. <el-input v-if="scope.row.Edit" v-model="scope.row.sort" step="0.01" type="number" style="width:95%;padding:10px 0;" min-number="0" @blur="blurSort(scope.row)" />
  242. </template>
  243. </el-table-column>
  244. <el-table-column label="操作" align="center" width="320" class-name="small-padding fixed-width" fixed="right">
  245. <template slot-scope="{row}">
  246. <!-- 新增 -->
  247. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData2(row)">保存</el-button>
  248. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  249. <!-- 编辑 -->
  250. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">编辑</el-button>
  251. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  252. <!-- 编辑保存 -->
  253. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData2(row)">保存</el-button>
  254. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  255. <!-- 拆分预混料 -->
  256. <el-button v-if="parseInt(row.preftid)>0 && row.isUpdateSave==false" class="miniSuccess" @click="handleSplitPremix(row)">拆分预混料</el-button>
  257. </template>
  258. </el-table-column>
  259. </el-table>
  260. </div>
  261. </div>
  262. <!-- 配方记录 -->
  263. <el-dialog :title="textMap[template.dialogStatus]" :destroy-on-close="true" :visible.sync="template.dialogFormVisible" :close-on-click-modal="false" width="90%">
  264. <div style="height: 400px;overflow: auto;margin-bottom: 30px;">
  265. <div ref="templateDialog" class="templateDialog">
  266. <p class="recipeTemplate" />
  267. <div class="operation">
  268. <el-date-picker v-model="template.table.getdataListParm.parammaps.date" type="date" placeholder="请选择历史记录时间" :clearable="false" style="width: 180px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" @change="changeDate" />
  269. <!-- <el-button class="successBorder" @click="handleApplication">应用</el-button> -->
  270. </div>
  271. <div class="search">
  272. <el-select v-model="template.table.getdataListParm.parammaps.ccname" placeholder="牲畜类别" class="filter-item" clearable>
  273. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.label" />
  274. </el-select>
  275. <el-select v-model="template.table.getdataListParm.parammaps.fttype" placeholder="配方类型" class="filter-item" style="width: 120px;" clearable>
  276. <el-option v-for="item in formulaTypeList" :key="item.value" :label="item.label" :value="item.label" />
  277. </el-select>
  278. <el-select v-model="template.table.getdataListParm.parammaps.enable" placeholder="是否启用" class="filter-item" style="width: 120px;" clearable>
  279. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.id" />
  280. </el-select>
  281. <div ref="selectInput" class="filter-item selectInput">
  282. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  283. <i v-if="arrowDown" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  284. <i v-if="arrowUp" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  285. <ul v-if="arrowUp" class="selectUl">
  286. <li><a>配方名称</a><el-input v-model="template.table.getdataListParm.parammaps.tname" style="width: 245px;" /></li>
  287. <li><a>备注</a><el-input v-model="template.table.getdataListParm.parammaps.remark" style="width: 245px;" /></li>
  288. <li><a>来源</a><el-input v-model="template.table.getdataListParm.parammaps.source" style="width: 245px;" /></li>
  289. <li>
  290. <div style="float: right;">
  291. <el-button class="minCancel" @click="arrowUp=false;arrowDown=true;">取消</el-button>
  292. <el-button class="miniSuccess" @click="handleDialogSearch">搜索</el-button>
  293. </div>
  294. </li>
  295. </ul>
  296. </div>
  297. <el-button class="successBorder" @click="handleDialogSearch">查询</el-button>
  298. <el-button class="successBorder" @click="handleDialogRefresh">重置</el-button>
  299. </div>
  300. <div class="table">
  301. <el-table
  302. :key="template.table.tableKey"
  303. v-loading="template.table.listLoading"
  304. element-loading-text="给我一点时间"
  305. :data="template.table.list"
  306. border
  307. fit
  308. highlight-current-row
  309. style="width: 98%;"
  310. :row-style="rowStyle"
  311. :cell-style="cellStyle"
  312. class="elTable table-fixed"
  313. @row-click="tableRowClickDialog"
  314. >
  315. <el-table-column label="序号" align="center" type="index" width="50px">
  316. <template slot-scope="scope">
  317. <span>{{ scope.$index + (template.table.pageNum-1) * template.table.pageSize + 1 }}</span>
  318. </template>
  319. </el-table-column>
  320. <el-table-column label="配方名称" min-width="130px" align="center">
  321. <template slot-scope="scope">
  322. <span>{{ scope.row.tname }}</span>
  323. </template>
  324. </el-table-column>
  325. <el-table-column label="配方颜色" min-width="130px" align="center">
  326. <template slot-scope="scope">
  327. <el-color-picker v-model="scope.row.tcolor" size="mini" disabled style="margin:10px 0;" />
  328. </template>
  329. </el-table-column>
  330. <el-table-column label="牲畜类别" min-width="150px" align="center">
  331. <template slot-scope="scope">
  332. <span>{{ scope.row.ccname }}</span>
  333. </template>
  334. </el-table-column>
  335. <el-table-column label="配方类型" min-width="150px" align="center">
  336. <template slot-scope="scope">
  337. <span>{{ scope.row.fttype }}</span>
  338. </template>
  339. </el-table-column>
  340. <el-table-column label="来源" min-width="110px" align="center">
  341. <template slot-scope="scope">
  342. <span>{{ scope.row.source }}</span>
  343. </template>
  344. </el-table-column>
  345. <el-table-column label="备注" min-width="110px" align="center">
  346. <template slot-scope="scope">
  347. <span>{{ scope.row.remark }}</span>
  348. </template>
  349. </el-table-column>
  350. <el-table-column label="是否启用" min-width="110px" align="center">
  351. <template slot-scope="scope">
  352. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  353. </template>
  354. </el-table-column>
  355. </el-table>
  356. </div>
  357. </div>
  358. <div v-if="isDetailDialog" class="detailDialog" style="margin-top: 30px;">
  359. <p class="recipeDetail" />
  360. <div class="operation">
  361. <div ref="selectInput2" class="filter-item selectInput">
  362. <el-input type="text" name="" value="" placeholder="请点击选择搜索条件" class="Input" />
  363. <i v-if="arrowDown2" icon="el-icon-arrow-down" class="el-icon-arrow-down" />
  364. <i v-if="arrowUp2" icon="el-icon-arrow-up" class="el-icon-arrow-up" />
  365. <ul v-if="arrowUp2" class="selectUl" style="width: 400px;">
  366. <li>
  367. <a style="width: 130px;">饲料名称</a>
  368. <el-select v-model="template.table2.getdataListParm.parammaps.fname" filterable placeholder="" style="width:245px;">
  369. <el-option v-for="item in feedNameList" :key="item.id" :label="item.fname" :value="item.fname" />
  370. </el-select>
  371. </li>
  372. <li><a style="width: 130px;">饲料组名称</a><el-input v-model="template.table2.getdataListParm.parammaps.feedgroup" style="width: 245px;" /></li>
  373. <li><a style="width: 130px;">重量</a><el-input v-model="template.table2.getdataListParm.parammaps.fweight" style="width: 245px;" /></li>
  374. <li>
  375. <a style="width: 130px;">搅拌延时</a>
  376. <el-select v-model="template.table2.getdataListParm.parammaps.autosecondname" filterable placeholder="" style="width:245px;">
  377. <el-option v-for="item in mixingDelayList" :key="item.id" :label="item.name" :value="item.name" />
  378. </el-select>
  379. </li>
  380. <li>
  381. <a style="width: 130px;">是否锁定牛头数比例</a>
  382. <el-select v-model="template.table2.getdataListParm.parammaps.islockcount" placeholder="" style="width:245px;">
  383. <el-option v-for="item in lockBullsList" :key="item.id" :label="item.name" :value="item.id" />
  384. </el-select>
  385. </li>
  386. <li><a style="width: 130px;">顺序</a><el-input v-model="template.table2.getdataListParm.parammaps.sort" style="width: 245px;" /></li>
  387. <li>
  388. <div style="float: right;">
  389. <el-button class="minCancel" @click="arrowUp2=false;arrowDown2=true;">取消</el-button>
  390. <el-button class="miniSuccess" @click="handleDialogSearch2">搜索</el-button>
  391. </div>
  392. </li>
  393. </ul>
  394. </div>
  395. <el-button class="successBorder" @click="handleDialogSearch2">查询</el-button>
  396. <el-button class="successBorder" @click="handleDialogRefresh2">重置</el-button>
  397. </div>
  398. <div class="table2">
  399. <el-table
  400. :key="template.table2.tableKey"
  401. v-loading="template.table2.listLoading"
  402. element-loading-text="给我一点时间"
  403. :data="template.table2.list"
  404. border
  405. fit
  406. highlight-current-row
  407. style="width: 98%;"
  408. :row-style="rowStyle"
  409. :cell-style="cellStyle"
  410. class="elTable table-fixed"
  411. row-key="id"
  412. >
  413. <el-table-column label="饲料组" min-width="130px" align="center">
  414. <template slot-scope="scope">
  415. <span>{{ scope.row.feedgroup }}</span>
  416. </template>
  417. </el-table-column>
  418. <el-table-column label="饲料名称" min-width="130px" align="center">
  419. <template slot-scope="scope">
  420. <span>{{ scope.row.fname }}</span>
  421. </template>
  422. </el-table-column>
  423. <el-table-column label="重量(KG)" min-width="130px" align="center">
  424. <template slot-scope="scope">
  425. <span>{{ scope.row.fweight }}</span>
  426. </template>
  427. </el-table-column>
  428. <el-table-column label="搅拌延时(min)" min-width="130px" align="center">
  429. <template slot-scope="scope">
  430. <span>{{ scope.row.autosecondname }}</span>
  431. </template>
  432. </el-table-column>
  433. <el-table-column label="是否锁定牛头数比例" min-width="130px" align="center">
  434. <template slot-scope="scope">
  435. <span v-if="scope.row.islockcount == '0'">否</span>
  436. <span v-if="scope.row.islockcount == '1'">是</span>
  437. </template>
  438. </el-table-column>
  439. <el-table-column label="顺序" min-width="130px" align="center">
  440. <template slot-scope="scope">
  441. <span>{{ scope.row.sort }}</span>
  442. </template>
  443. </el-table-column>
  444. </el-table>
  445. </div>
  446. </div>
  447. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  448. <el-button @click="template.dialogFormVisible = false; ">关闭</el-button>
  449. </div>
  450. </div>
  451. </el-dialog>
  452. <!-- 合成预混料 -->
  453. <el-dialog :title="textMap[detail.dialogStatus]" :destroy-on-close="true" :visible.sync="detail.dialogFormVisible" :close-on-click-modal="false" width="90%">
  454. <div class="detailDialog">
  455. <h2>饲料</h2>
  456. <div class="table1">
  457. <el-table
  458. :key="detail.tableKey"
  459. v-loading="detail.listLoading"
  460. element-loading-text="给我一点时间"
  461. :data="detail.list"
  462. fit
  463. highlight-current-row
  464. style="width: 100%;"
  465. :row-style="rowStyle"
  466. :cell-style="cellStyle"
  467. class="elTable table-fixed"
  468. show-summary
  469. >
  470. <el-table-column label="序号" align="center" type="index" width="50px" />
  471. <el-table-column label="饲料名称" min-width="130px" align="center">
  472. <template slot-scope="scope">
  473. <span>{{ scope.row.fname }}</span>
  474. </template>
  475. </el-table-column>
  476. <el-table-column prop="fweight" label="重量(KG)" />
  477. <el-table-column label="搅拌延时(min)" min-width="110px" align="center">
  478. <template slot-scope="scope">
  479. <span>{{ scope.row.autosecond }}</span>
  480. </template>
  481. </el-table-column>
  482. <el-table-column v-if="lockCount.isLockCount" label="是否锁定牛头数比例" min-width="130px" align="center">
  483. <template slot-scope="scope">
  484. <span v-if="scope.row.islockcount == '0'">否</span>
  485. <span v-if="scope.row.islockcount == '1'">是</span>
  486. </template>
  487. </el-table-column>
  488. <el-table-column label="顺序" min-width="110px" align="center">
  489. <template slot-scope="scope">
  490. <span>{{ scope.row.sort }}</span>
  491. </template>
  492. </el-table-column>
  493. </el-table>
  494. </div>
  495. <h2>合成预混料</h2>
  496. <div class="table2" style="margin-bottom: 50px;">
  497. <el-table
  498. :key="detail.tableKey2"
  499. v-loading="detail.listLoading2"
  500. element-loading-text="给我一点时间"
  501. :data="detail.list2"
  502. border
  503. fit
  504. highlight-current-row
  505. style="width: 100%;"
  506. :row-style="rowStyle"
  507. :cell-style="cellStyle"
  508. class="elTable table-fixed"
  509. >
  510. <el-table-column label="配方名称" min-width="130px" align="center">
  511. <template slot-scope="scope">
  512. <el-input v-model="scope.row.tname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  513. </template>
  514. </el-table-column>
  515. <el-table-column label="配方颜色11" min-width="130px" align="center">
  516. <template slot-scope="scope">
  517. <el-color-picker v-model="scope.row.tcolor" size="mini" style="margin:10px 0;" :disabled="detail.disabled" />
  518. </template>
  519. </el-table-column>
  520. <el-table-column label="牲畜类别" min-width="130px" align="center">
  521. <template slot-scope="scope">
  522. <el-select v-model="scope.row.ccid" placeholder="选择牲畜父类" class="filter-item" style="width:95%;padding:10px 0;" :disabled="detail.disabled" @change="changeLivestockType2">
  523. <el-option v-for="item in livestockTypeList" :key="item.value" :label="item.label" :value="item.value" />
  524. </el-select>
  525. </template>
  526. </el-table-column>
  527. <el-table-column label="配方类型" min-width="110px" align="center">
  528. <template slot-scope="scope">
  529. <span>{{ scope.row.fttype }}</span>
  530. </template>
  531. </el-table-column>
  532. <el-table-column label="来源" min-width="110px" align="center">
  533. <template slot-scope="scope">
  534. <span>{{ scope.row.source }}</span>
  535. </template>
  536. </el-table-column>
  537. <el-table-column label="备注" min-width="130px" align="center">
  538. <template slot-scope="scope">
  539. <el-input v-model="scope.row.remark" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" style="width:95%;padding:10px 0;" :disabled="detail.disabled" />
  540. </template>
  541. </el-table-column>
  542. <el-table-column label="是否启用" min-width="130px" align="center">
  543. <template slot-scope="scope">
  544. <el-switch v-model="scope.row.enable" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" :disabled="detail.disabled" />
  545. </template>
  546. </el-table-column>
  547. </el-table>
  548. </div>
  549. <div slot="footer" class="dialog-footer" style="bottom: -50px;">
  550. <el-button class="cancelClose" @click="detail.dialogFormVisible = false; ">关闭</el-button>
  551. <el-button class="success" :disabled="isokDisable" @click="syntheticPremixData()">确认</el-button>
  552. </div>
  553. </div>
  554. </el-dialog>
  555. </div>
  556. </template>
  557. <script>
  558. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  559. import Sortable from 'sortablejs'
  560. import { MessageBox } from 'element-ui'
  561. import Cookies from 'js-cookie'
  562. import { json2excel } from '@/utils/index.js'
  563. import { getToken } from '@/utils/auth'
  564. export default {
  565. name: 'RecipeTemplate',
  566. data() {
  567. return {
  568. requestParams: [
  569. { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] },
  570. { name: 'getDictByName2', offset: 0, pagecount: 0, params: ['配方类型'] },
  571. { name: 'getFeedAndPre', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  572. ],
  573. enableList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否启用
  574. lockBullsList: [{ id: '0', name: '否' }, { id: '1', name: '是' }], // 是否锁定牛头数比例
  575. livestockTypeList: [], // 牲畜类别
  576. formulaTypeList: [], // 配方类型
  577. feedNameList: [], // 饲料名称
  578. mixingDelayList: [{ id: '0', name: '0' }, { id: '1', name: '1' }, { id: '2', name: '2' }, { id: '3', name: '3' }, { id: '4', name: '4' }, { id: '5', name: '5' }, { id: '6', name: '6' }, { id: '7', name: '7' }, { id: '8', name: '8' }, { id: '9', name: '9' }, { id: '10', name: '10' }, { id: '11', name: '11' }, { id: '12', name: '12' }, { id: '13', name: '13' }, { id: '14', name: '14' }, { id: '15', name: '15' }], // 搅拌延时
  579. selectHistoryTimeList: [{ id: 0, name: '2020-06-10' }, { id: 1, name: '2020-06-11' }, { id: 2, name: '2020-06-12' }, { id: 3, name: '2020-06-13' }], // 请选择历史记录时间
  580. sourceList: [{ id: 0, name: '自定义' }, { id: 1, name: '集团下发' }, { id: 2, name: '导入' }], // 导入
  581. arrowDown: true,
  582. arrowUp: false,
  583. table: {
  584. getdataListParm: {
  585. name: 'getFTList',
  586. page: 1,
  587. offset: 1,
  588. pagecount: 30,
  589. returntype: 'Map',
  590. parammaps: {
  591. pastureid: Cookies.get('pastureid'),
  592. tname: '',
  593. ccid: '',
  594. ccname: '',
  595. fttypeid: '',
  596. fttype: '',
  597. remark: '',
  598. enable: ''
  599. }
  600. },
  601. tableKey: 0,
  602. list: [],
  603. total: 0,
  604. listLoading: true,
  605. temp: {}
  606. },
  607. lockCount: {
  608. getdataListParm: {
  609. name: 'getSysoptEnable',
  610. page: 1,
  611. offset: 1,
  612. pagecount: 30,
  613. returntype: 'Map',
  614. parammaps: {
  615. pastureid: Cookies.get('pastureid'),
  616. inforname: 'isLockCount'
  617. }
  618. },
  619. isLockCount: false // 是否显示是否锁定牛头数比例
  620. },
  621. isDetail: false,
  622. arrowDown2: true,
  623. arrowUp2: false,
  624. table2: {
  625. getdataListParm: {
  626. name: 'getFTdetailList',
  627. page: 1,
  628. offset: 1,
  629. pagecount: 10,
  630. returntype: 'Map',
  631. parammaps: {
  632. pastureid: Cookies.get('pastureid'),
  633. fname: '',
  634. feedgroup: '',
  635. fweight: '',
  636. autosecondname: '',
  637. islockcount: '',
  638. sort: ''
  639. }
  640. },
  641. tableKey: 0,
  642. list: [],
  643. total: 0,
  644. listLoading: true,
  645. temp: {}
  646. },
  647. isDetailDialog: false,
  648. template: {
  649. dialogFormVisible: false,
  650. dialogStatus: '',
  651. table: {
  652. getdataListParm: {
  653. name: 'getFTListDate',
  654. page: 1,
  655. offset: 1,
  656. pagecount: 10,
  657. returntype: 'Map',
  658. parammaps: {
  659. pastureid: Cookies.get('pastureid'),
  660. tname: '',
  661. ccid: '',
  662. ccname: '',
  663. fttype: '',
  664. remark: '',
  665. enable: '',
  666. date: '',
  667. source: ''
  668. }
  669. },
  670. tableKey: 0,
  671. total: 0,
  672. listLoading: true,
  673. list: []
  674. },
  675. table2: {
  676. getdataListParm: {
  677. name: 'getFTdetailListDate',
  678. page: 1,
  679. offset: 1,
  680. pagecount: 10,
  681. returntype: 'Map',
  682. parammaps: {
  683. pastureid: Cookies.get('pastureid'),
  684. fname: '',
  685. fweight: '',
  686. islockcount: '',
  687. sort: '',
  688. feedgroup: '',
  689. autosecondname: ''
  690. }
  691. },
  692. tableKey: 0,
  693. total: 0,
  694. listLoading: true,
  695. list: []
  696. },
  697. // 历史日期
  698. getdataDateParm: {
  699. name: 'getFTMaxDate',
  700. page: 1,
  701. offset: 1,
  702. pagecount: 10,
  703. returntype: 'Map',
  704. parammaps: {
  705. pastureid: Cookies.get('pastureid')
  706. }
  707. }
  708. },
  709. detail: {
  710. dialogFormVisible: false,
  711. dialogStatus: '',
  712. tableKey: 0,
  713. total: 0,
  714. listLoading: true,
  715. list: [],
  716. tableKey2: 0,
  717. total2: 0,
  718. listLoading2: false,
  719. list2: [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }],
  720. getdataListParm: {
  721. name: 'getFTDetailCompare',
  722. page: 1,
  723. offset: 1,
  724. pagecount: 10,
  725. returntype: 'Map',
  726. parammaps: {}
  727. },
  728. list3: [],
  729. disabled: false,
  730. getdataListParm2: {
  731. name: 'getFTCompare',
  732. page: 1,
  733. offset: 1,
  734. pagecount: 10,
  735. returntype: 'Map',
  736. parammaps: {}
  737. }
  738. },
  739. selectList: [],
  740. selectList2: [],
  741. textMap: {
  742. RecipeRecord: '配方记录',
  743. SyntheticPremix: '合成预混料'
  744. },
  745. requestParam: {},
  746. download: {
  747. getdataListParm: {
  748. name: 'getFTList',
  749. page: 1,
  750. offset: 1,
  751. pagecount: 0,
  752. returntype: 'Map',
  753. parammaps: {
  754. pastureid: Cookies.get('pastureid'),
  755. tname: '',
  756. ccid: '',
  757. ccname: '',
  758. fttypeid: '',
  759. fttype: '',
  760. remark: '',
  761. enable: ''
  762. }
  763. },
  764. list: []
  765. },
  766. isokDisable: false,
  767. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  768. cellStyle: { padding: 0 + 'px' },
  769. dropState: false
  770. }
  771. },
  772. computed: {
  773. // 设置请求头
  774. headers() {
  775. return {
  776. token: getToken()
  777. }
  778. },
  779. uploadData() {
  780. return {
  781. name: '颛孙洋洋-配方模板',
  782. importParams: '配方名称, 牲畜类别, 配方类型, 备注, 是否启用, 饲料组, 饲料名称, 重量(kg), 搅拌延时(min), 是否锁定牛头数比例',
  783. sheetname: 'SheetJS'
  784. }
  785. },
  786. // 设置上传地址
  787. uploadExcelUrl() {
  788. return process.env.VUE_APP_BASE_API + 'authdata/ImportExcel'
  789. }
  790. },
  791. mounted() {
  792. document.addEventListener('click', (e) => {
  793. if (this.$refs.selectInput !== undefined) {
  794. if (!this.$refs.selectInput.contains(e.target)) {
  795. this.arrowDown = true
  796. this.arrowUp = false
  797. } else {
  798. this.arrowDown = false
  799. this.arrowUp = true
  800. }
  801. }
  802. if (this.$refs.selectInput2 !== undefined) {
  803. if (!this.$refs.selectInput2.contains(e.target)) {
  804. this.arrowDown2 = true
  805. this.arrowUp2 = false
  806. } else {
  807. this.arrowDown2 = false
  808. this.arrowUp2 = true
  809. }
  810. }
  811. })
  812. },
  813. created() {
  814. this.getList()
  815. this.getDownList()
  816. this.getIsLockCount()
  817. },
  818. methods: {
  819. handleHistory() {
  820. MessageBox.confirm('是否确认生成历史?', {
  821. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  822. }).then(() => {
  823. this.requestParam.name = 'creatFTdate'
  824. this.requestParam.parammaps = {}
  825. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  826. PostDataByName(this.requestParam).then(response => {
  827. console.log('生成历史保存发送参数', this.requestParam)
  828. if (response.msg !== 'fail') {
  829. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  830. } else {
  831. failproccess(response, this.$notify)
  832. }
  833. })
  834. })
  835. },
  836. getDownList() {
  837. GetDataByNames(this.requestParams).then(response => {
  838. this.livestockTypeList = response.data.getDictByName.list
  839. this.formulaTypeList = response.data.getDictByName2.list
  840. this.feedNameList = response.data.getFeedAndPre.list
  841. })
  842. },
  843. // -------------------模板-----------------------------
  844. getList() {
  845. this.table.listLoading = true
  846. GetDataByName(this.table.getdataListParm).then(response => {
  847. console.log('table数据', response.data.list)
  848. if (response.data.list !== null) {
  849. for (let i = 0; i < response.data.list.length; i++) {
  850. this.$set(response.data.list[i], 'Edit', false) // 编辑
  851. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  852. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  853. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  854. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  855. }
  856. this.table.list = response.data.list
  857. this.table.pageNum = response.data.pageNum
  858. this.table.pageSize = response.data.pageSize
  859. this.table.total = response.data.total
  860. } else {
  861. this.table.list = []
  862. }
  863. setTimeout(() => {
  864. this.table.listLoading = false
  865. }, 100)
  866. })
  867. },
  868. handleSearch() {
  869. console.log('点击了查询')
  870. this.table.getdataListParm.offset = 1
  871. this.getList()
  872. this.arrowDown = true
  873. this.arrowUp = false
  874. },
  875. handleRefresh() {
  876. console.log('点击了重置')
  877. this.table.getdataListParm.offset = 1
  878. this.table.getdataListParm.parammaps.ccid = ''
  879. this.table.getdataListParm.parammaps.ccname = ''
  880. this.table.getdataListParm.parammaps.fttype = ''
  881. this.table.getdataListParm.parammaps.tname = ''
  882. this.table.getdataListParm.parammaps.remark = ''
  883. this.table.getdataListParm.parammaps.enable = ''
  884. this.table.getdataListParm.parammaps.source = ''
  885. this.getList()
  886. },
  887. // 模板新增
  888. handleCreate() {
  889. console.log('点击了新增')
  890. // 编辑true/不可编辑false
  891. // 新增操true,编辑false,编辑保存false
  892. for (let i = 0; i < this.table.list.length; i++) {
  893. if (this.table.list[i].Edit === true) {
  894. console.log(123)
  895. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  896. return false
  897. }
  898. }
  899. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'tname': '', 'tcolor': '#ccc', 'ccid': '', 'ccname': '', 'fttype': '', 'fttypeid': '', 'source': '自定义', 'remark': '' })
  900. console.log(this.table.list)
  901. },
  902. // 畜生类别
  903. changeLivestockType(item) {
  904. this.table.temp.ccname = this.livestockTypeList.find(obj => obj.value === item).label
  905. },
  906. // 配方类型
  907. changeFormulaType(item) {
  908. this.table.temp.fttype = this.formulaTypeList.find(obj => obj.value === item).label
  909. },
  910. createData(row) {
  911. console.log('点击了新增保存', row)
  912. this.table.temp.tname = row.tname
  913. this.table.temp.tcolor = row.tcolor
  914. this.table.temp.ccid = row.ccid
  915. this.table.temp.ccname = this.table.temp.ccname
  916. this.table.temp.fttype = this.table.temp.fttype
  917. this.table.temp.fttypeid = row.fttypeid
  918. this.table.temp.source = row.source
  919. this.table.temp.remark = row.remark
  920. this.table.temp.enable = row.enable
  921. this.table.temp.pastureid = Cookies.get('pastureid')
  922. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  923. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  924. return false
  925. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  926. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  927. return false
  928. } else if (this.table.temp.tname == '') {
  929. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  930. return false
  931. } else if (this.table.temp.ccid == '') {
  932. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  933. return false
  934. } else if (this.table.temp.fttypeid == '') {
  935. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  936. return false
  937. }
  938. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  939. if (pattern.test(this.table.temp.tname)) {
  940. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  941. return false
  942. }
  943. console.log(this.table.temp)
  944. this.isokDisable = true
  945. setTimeout(() => {
  946. this.isokDisable = false
  947. }, 1000)
  948. this.requestParam.name = 'insertFT'
  949. this.requestParam.parammaps = this.table.temp
  950. PostDataByName(this.requestParam).then(response => {
  951. console.log('新增保存发送参数', this.requestParam)
  952. if (response.msg !== 'fail') {
  953. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  954. this.getList()
  955. } else {
  956. failproccess(response, this.$notify)
  957. }
  958. })
  959. },
  960. createCancel(row) {
  961. console.log('点击了新增取消')
  962. for (let i = 0; i < this.table.list.length; i++) {
  963. if (row.myId === this.table.list[i].myId) {
  964. var listIndex = this.table.list.indexOf(this.table.list[i])
  965. }
  966. if (listIndex > -1) {
  967. this.table.list.splice(listIndex, 1)
  968. return
  969. }
  970. }
  971. },
  972. // 模板编辑
  973. handleUpdate(row) {
  974. for (let i = 0; i < this.table.list.length; i++) {
  975. if (this.table.list[i].Edit == true) {
  976. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  977. return false
  978. }
  979. }
  980. // 编辑true,不可编辑false
  981. row.Edit = true
  982. row.NoEdit = false
  983. // 新增false,编辑false,编辑保存true
  984. row.isCreate = false
  985. row.isUpdate = false
  986. row.isUpdateSave = true
  987. row.ccid = String(row.ccid)
  988. row.fttypeid = String(row.fttypeid)
  989. this.table.temp.ccname = row.ccname
  990. this.table.temp.fttype = row.fttype
  991. },
  992. updateData(row) {
  993. console.log('点击了编辑保存', row)
  994. this.table.temp.tname = row.tname
  995. this.table.temp.tcolor = row.tcolor
  996. this.table.temp.ccid = row.ccid
  997. this.table.temp.fttypeid = row.fttypeid
  998. this.table.temp.source = row.source
  999. this.table.temp.remark = row.remark
  1000. this.table.temp.enable = row.enable
  1001. this.table.temp.ccname = this.table.temp.ccname
  1002. this.table.temp.fttype = this.table.temp.fttype
  1003. this.table.temp.pastureid = row.pastureid
  1004. this.table.temp.id = row.id
  1005. if (this.table.temp.tname == '' && this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1006. this.$message({ type: 'error', message: '配方名称/牲畜类别/配方类型不能为空', duration: 2000 })
  1007. return false
  1008. } else if (this.table.temp.ccid == '' && this.table.temp.fttypeid == '') {
  1009. this.$message({ type: 'error', message: '牲畜类别/配方类型不能为空', duration: 2000 })
  1010. return false
  1011. } else if (this.table.temp.tname == '') {
  1012. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  1013. return false
  1014. } else if (this.table.temp.ccid == '') {
  1015. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  1016. return false
  1017. } else if (this.table.temp.fttypeid == '') {
  1018. this.$message({ type: 'error', message: '配方类型不能为空', duration: 2000 })
  1019. return false
  1020. }
  1021. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1022. if (pattern.test(this.table.temp.tname)) {
  1023. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  1024. return false
  1025. }
  1026. console.log(this.table.temp)
  1027. this.isokDisable = true
  1028. setTimeout(() => {
  1029. this.isokDisable = false
  1030. }, 1000)
  1031. this.requestParam.name = 'updateFT'
  1032. this.requestParam.parammaps = this.table.temp
  1033. PostDataByName(this.requestParam).then(response => {
  1034. console.log('新增保存发送参数', this.requestParam)
  1035. if (response.msg !== 'fail') {
  1036. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1037. this.getList()
  1038. } else {
  1039. failproccess(response, this.$notify)
  1040. }
  1041. })
  1042. },
  1043. updateCancel(row) {
  1044. console.log('点击了编辑取消')
  1045. // 编辑false,不可编辑true
  1046. row.Edit = false
  1047. row.NoEdit = true
  1048. // 新增false,编辑true,编辑保存false
  1049. row.isCreate = false
  1050. row.isUpdate = true
  1051. row.isUpdateSave = false
  1052. this.getList()
  1053. },
  1054. // 删除
  1055. handleRowDelete(row) {
  1056. console.log('点击了行内删除')
  1057. MessageBox.confirm('是否确认删除此信息?', {
  1058. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1059. }).then(() => {
  1060. this.requestParam.common = { 'returnmap': '0' }
  1061. this.requestParam.data = []
  1062. this.requestParam.data[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1063. pastureid: row.pastureid,
  1064. id: row.id
  1065. }}
  1066. this.requestParam.data[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1067. pastureid: row.pastureid,
  1068. id: row.id
  1069. }}
  1070. ExecDataByConfig(this.requestParam).then(response => {
  1071. console.log('新增保存发送参数', this.requestParam)
  1072. if (response.msg === 'fail') {
  1073. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1074. } else {
  1075. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1076. this.getList()
  1077. this.isDetail = false
  1078. }
  1079. })
  1080. }).catch(() => {
  1081. this.$message({ type: 'info', message: '已取消删除' })
  1082. })
  1083. },
  1084. handleSelectionChange(val) {
  1085. console.log('勾选数据', val)
  1086. this.selectList = val
  1087. },
  1088. handleDelete() {
  1089. console.log('点击了删除')
  1090. if (this.selectList.length == 0) {
  1091. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1092. } else {
  1093. MessageBox.confirm('是否确认删除此信息?', {
  1094. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1095. }).then(() => {
  1096. console.log(this.selectList)
  1097. this.requestParam.common = { 'returnmap': '0' }
  1098. this.requestParam.data = []
  1099. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1100. this.requestParam.data[0].children = []
  1101. this.requestParam.data[0].children[0] = { 'name': 'checkdeleteFT', 'type': 'v', 'parammaps': {
  1102. id: '@insertSpotList.id',
  1103. pastureid: '@insertSpotList.pastureid'
  1104. }}
  1105. this.requestParam.data[0].children[1] = { 'name': 'deleteFT', 'type': 'e', 'parammaps': {
  1106. id: '@insertSpotList.id',
  1107. pastureid: '@insertSpotList.pastureid'
  1108. }}
  1109. ExecDataByConfig(this.requestParam).then(response => {
  1110. console.log('删除保存发送参数', this.requestParam)
  1111. if (response.msg === 'fail') {
  1112. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1113. } else {
  1114. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1115. this.getList()
  1116. }
  1117. })
  1118. })
  1119. }
  1120. },
  1121. // 复制
  1122. handleCopy() {
  1123. if (this.selectList.length == 0) {
  1124. this.$message({ type: 'error', message: '请选择配方', duration: 2000 })
  1125. } else {
  1126. MessageBox.confirm('是否确认复制此信息?', {
  1127. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1128. }).then(() => {
  1129. console.log(this.selectList)
  1130. this.requestParam.common = { 'returnmap': '0' }
  1131. this.requestParam.data = []
  1132. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  1133. this.requestParam.data[0].children = []
  1134. this.requestParam.data[0].children[0] = { 'name': 'copyFT', 'type': 'e', 'parammaps': {
  1135. ftid: '@insertSpotList.id',
  1136. pastureid: '@insertSpotList.pastureid'
  1137. }}
  1138. ExecDataByConfig(this.requestParam).then(response => {
  1139. console.log('复制保存发送参数', this.requestParam)
  1140. if (response.msg === 'fail') {
  1141. this.$notify({ title: '复制失败', message: response.data, type: 'warning', duration: 2000 })
  1142. } else {
  1143. this.$notify({ title: '', message: '复制成功', type: 'success', duration: 2000 })
  1144. this.getList()
  1145. }
  1146. })
  1147. })
  1148. }
  1149. },
  1150. // 配方记录
  1151. handleRecipeRecord() {
  1152. console.log('点击了配方记录')
  1153. this.template.dialogStatus = 'RecipeRecord'
  1154. this.template.dialogFormVisible = true
  1155. this.template.table.getdataListParm.parammaps.ccname = ''
  1156. this.template.table.getdataListParm.parammaps.fttype = ''
  1157. this.template.table.getdataListParm.parammaps.enable = ''
  1158. this.template.table.getdataListParm.parammaps.tname = ''
  1159. this.template.table.getdataListParm.parammaps.remark = ''
  1160. this.template.table.getdataListParm.parammaps.source = ''
  1161. this.template.table.getdataListParm.offset = 1
  1162. this.getDateList()
  1163. this.isDetailDialog = false
  1164. },
  1165. // 历史时间
  1166. getDateList() {
  1167. GetDataByName(this.template.getdataDateParm).then(response => {
  1168. console.log('table数据', response.data.list)
  1169. if (response.data.list !== null) {
  1170. this.template.table.getdataListParm.parammaps.date = response.data.list[0].maxdate
  1171. this.getTemplateDialogList()
  1172. } else {
  1173. this.template.table.getdataListParm.parammaps.date = ''
  1174. }
  1175. })
  1176. },
  1177. // 配方记录-模板
  1178. getTemplateDialogList() {
  1179. this.template.table.listLoading = true
  1180. GetDataByName(this.template.table.getdataListParm).then(response => {
  1181. console.log('table数据', response.data.list)
  1182. if (response.data.list !== null) {
  1183. this.template.table.list = response.data.list
  1184. this.template.table.pageNum = response.data.pageNum
  1185. this.template.table.pageSize = response.data.pageSize
  1186. this.template.table.total = response.data.total
  1187. } else {
  1188. this.template.table.list = []
  1189. }
  1190. setTimeout(() => {
  1191. this.template.table.listLoading = false
  1192. }, 100)
  1193. })
  1194. },
  1195. handleDialogSearch() {
  1196. this.template.table.getdataListParm.offset = 1
  1197. this.getTemplateDialogList()
  1198. this.arrowDown = true
  1199. this.arrowUp = false
  1200. },
  1201. handleDialogRefresh() {
  1202. this.template.table.getdataListParm.parammaps.ccname = ''
  1203. this.template.table.getdataListParm.parammaps.fttype = ''
  1204. this.template.table.getdataListParm.parammaps.enable = ''
  1205. this.template.table.getdataListParm.parammaps.tname = ''
  1206. this.template.table.getdataListParm.parammaps.remark = ''
  1207. this.template.table.getdataListParm.parammaps.source = ''
  1208. this.template.table.getdataListParm.offset = 1
  1209. this.getTemplateDialogList()
  1210. },
  1211. // 配方记录-模板行点击
  1212. tableRowClickDialog(row, column, event) {
  1213. console.log('配方记录-模板行点击')
  1214. this.isDetailDialog = true
  1215. this.template.table2.getdataListParm.parammaps.ftid = row.id
  1216. this.getDialogList()
  1217. this.getDownList()
  1218. },
  1219. getDialogList() {
  1220. this.template.table2.listLoading = true
  1221. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1222. console.log('table数据', response.data.list)
  1223. if (response.data.list !== null) {
  1224. this.template.table2.list = response.data.list
  1225. this.template.table2.pageNum = response.data.pageNum
  1226. this.template.table2.pageSize = response.data.pageSize
  1227. this.template.table2.total = response.data.total
  1228. } else {
  1229. this.template.table2.list = []
  1230. }
  1231. setTimeout(() => {
  1232. this.template.table2.listLoading = false
  1233. }, 100)
  1234. })
  1235. },
  1236. handleDialogSearch2() {
  1237. console.log('点击了查询')
  1238. this.arrowDown2 = true
  1239. this.arrowUp2 = false
  1240. this.template.table2.getdataListParm.offset = 1
  1241. this.getDialogList2()
  1242. },
  1243. handleDialogRefresh2() {
  1244. console.log('点击了重置')
  1245. this.template.table2.getdataListParm.parammaps.fname = ''
  1246. this.template.table2.getdataListParm.parammaps.feedgroup = ''
  1247. this.template.table2.getdataListParm.parammaps.fweight = ''
  1248. this.template.table2.getdataListParm.parammaps.autosecondname = ''
  1249. this.template.table2.getdataListParm.parammaps.islockcount = '0'
  1250. this.template.table2.getdataListParm.parammaps.sort = ''
  1251. this.template.table2.getdataListParm.offset = 1
  1252. this.getDialogList2()
  1253. },
  1254. getDialogList2() {
  1255. this.template.table2.listLoading = true
  1256. GetDataByName(this.template.table2.getdataListParm).then(response => {
  1257. console.log('table数据', response.data.list)
  1258. if (response.data.list !== null) {
  1259. this.template.table2.list = response.data.list
  1260. this.template.table2.pageNum = response.data.pageNum
  1261. this.template.table2.pageSize = response.data.pageSize
  1262. this.template.table2.total = response.data.total
  1263. } else {
  1264. this.template.table2.list = []
  1265. }
  1266. this.$nextTick(function() {
  1267. window.scrollTo({
  1268. 'top': this.$refs.templateDialog.clientHeight
  1269. })
  1270. })
  1271. setTimeout(() => {
  1272. this.template.table2.listLoading = false
  1273. }, 100)
  1274. })
  1275. },
  1276. // 导出
  1277. handleExport(item) {
  1278. if (item == 1) {
  1279. console.log('点击了导出模板')
  1280. } else {
  1281. console.log('点击了导出数据')
  1282. this.download.getdataListParm.parammaps = this.table.getdataListParm.parammaps
  1283. GetDataByName(this.download.getdataListParm).then(response => {
  1284. if (response.data.list !== null) {
  1285. for (let i = 0; i < response.data.list.length; i++) {
  1286. if (response.data.list[i].islockcount == 0) {
  1287. this.$set(response.data.list[i], 'islockcount', '否')
  1288. } else {
  1289. this.$set(response.data.list[i], 'islockcount', '是')
  1290. }
  1291. if (response.data.list[i].enable == 0) {
  1292. this.$set(response.data.list[i], 'enable', '否')
  1293. } else {
  1294. this.$set(response.data.list[i], 'enable', '是')
  1295. }
  1296. }
  1297. this.download.list = response.data.list
  1298. } else {
  1299. this.download.list = []
  1300. }
  1301. var excelDatas = [
  1302. {
  1303. tHeader: ['配方名称', '牲畜类别', '配方类型', '来源', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '顺序'],
  1304. filterVal: ['tname', 'ccname', 'fttype', 'source', 'remark', 'enable', 'feedgroup', 'fname', 'fweight', 'autosecond', 'islockcount', 'sort'],
  1305. tableDatas: this.download.list,
  1306. sheetName: 'Sheet1'
  1307. }
  1308. ]
  1309. json2excel(excelDatas, '配方模板', true, 'xlsx')
  1310. })
  1311. }
  1312. },
  1313. beforeImport(file) {
  1314. const isLt2M = file.size / 1024 / 1024 < 2
  1315. if (!isLt2M) {
  1316. this.$message.error('上传文件大小不能超过 2MB!')
  1317. }
  1318. return isLt2M
  1319. },
  1320. handleImportSuccess(res, file) {
  1321. this.getList()
  1322. if (res.msg === 'ok') {
  1323. this.$message({ title: '成功', message: '导入成功:' + res.data.success + '条!', type: 'success', duration: 2000 })
  1324. if (res.data.err_count > 0) {
  1325. this.$notify({ title: '失败', message: '导入失败:' + res.data.err_count + '条!', type: 'danger', duration: 2000 })
  1326. import('@/vendor/Export2Excel').then(excel => {
  1327. const list1 = res.data.result
  1328. const tHeader = [
  1329. '配方名称', '牲畜类别', '配方类型', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', '错误信息'
  1330. ]
  1331. const filterVal = [
  1332. '配方名称', '牲畜类别', '配方类型', '备注', '是否启用', '饲料组', '饲料名称', '重量(kg)', '搅拌延时(min)', '是否锁定牛头数比例', 'error_msg'
  1333. ]
  1334. const data1 = this.formatJson(filterVal, list1)
  1335. excel.export_json_to_excel({ header: tHeader, data: data1, filename: '配方模板导入报错信息', autoWidth: true, bookType: 'xlsx' })
  1336. })
  1337. }
  1338. } else {
  1339. this.$notify({ title: '失败', message: '上传失败', type: 'danger', duration: 2000 })
  1340. }
  1341. },
  1342. formatJson(filterVal, jsonData) {
  1343. return jsonData.map(v =>
  1344. filterVal.map(j => {
  1345. if (j === 'timestamp') {
  1346. return parseTime(v[j])
  1347. } else {
  1348. return v[j]
  1349. }
  1350. })
  1351. )
  1352. },
  1353. changeDate() {
  1354. this.getTemplateDialogList()
  1355. },
  1356. // 应用
  1357. handleApplication() {
  1358. console.log('点击了应用')
  1359. MessageBox.confirm('是否确认将' + this.template.table.getdataListParm.parammaps.date + '的数据应用到当前?', {
  1360. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1361. }).then(() => {
  1362. this.requestParam.name = 'applyFTdate'
  1363. this.requestParam.parammaps = {}
  1364. this.requestParam.parammaps.pastureid = Cookies.get('pastureid')
  1365. this.requestParam.parammaps.date = this.template.table.getdataListParm.parammaps.date
  1366. PostDataByName(this.requestParam).then(response => {
  1367. if (response.msg === 'fail') {
  1368. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1369. } else {
  1370. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1371. this.getTemplateDialogList()
  1372. this.getList()
  1373. }
  1374. })
  1375. }).catch(() => {
  1376. this.$message({ type: 'info', message: '已取消应用' })
  1377. })
  1378. },
  1379. // 模板行点击
  1380. tableRowClick(row, column, event) {
  1381. console.log(row, column, event)
  1382. for (let i = 0; i < this.table.list.length; i++) {
  1383. if (this.table.list[i].Edit == true) {
  1384. return false
  1385. }
  1386. }
  1387. if (column.label !== '操作') {
  1388. this.isDetail = true // 点击行显示详情
  1389. this.table2.getdataListParm.parammaps.ftid = row.id
  1390. this.table2.getdataListParm.parammaps.fttypeid = row.fttypeid
  1391. this.getList2()
  1392. this.getDownList()
  1393. }
  1394. },
  1395. // -------------------详情-----------------------------
  1396. // 获取是否显示是否锁定牛头数
  1397. getIsLockCount() {
  1398. GetDataByName(this.lockCount.getdataListParm).then(response => {
  1399. console.log(response.data.list)
  1400. if (response.data.list[0].inforvalue == 0) {
  1401. this.lockCount.isLockCount = false
  1402. } else {
  1403. this.lockCount.isLockCount = true
  1404. }
  1405. })
  1406. },
  1407. // 详情
  1408. getList2() {
  1409. this.table2.listLoading = true
  1410. GetDataByName(this.table2.getdataListParm).then(response => {
  1411. console.log('table数据', response.data.list)
  1412. if (response.data.list !== null) {
  1413. for (let i = 0; i < response.data.list.length; i++) {
  1414. this.$set(response.data.list[i], 'Edit', false) // 编辑
  1415. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  1416. this.$set(response.data.list[i], 'groupEdit', false) // 饲料组编辑
  1417. this.$set(response.data.list[i], 'isGroupDisabled', false) // 饲料组编辑禁止编辑
  1418. this.$set(response.data.list[i], 'groupNoEdit', true) // 饲料组不可编辑
  1419. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  1420. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  1421. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  1422. }
  1423. this.table2.list = response.data.list
  1424. this.table2.pageNum = response.data.pageNum
  1425. this.table2.pageSize = response.data.pageSize
  1426. this.table2.total = response.data.total
  1427. this.rowDrop()
  1428. } else {
  1429. this.table2.list = []
  1430. }
  1431. this.$nextTick(function() {
  1432. console.log(this.$refs)
  1433. console.log(this.$refs.template.clientHeight)
  1434. window.scrollTo({
  1435. 'top': this.$refs.template.clientHeight
  1436. })
  1437. })
  1438. setTimeout(() => {
  1439. this.table2.listLoading = false
  1440. }, 100)
  1441. })
  1442. },
  1443. // 行拖拽
  1444. rowDrop() {
  1445. console.log(1111)
  1446. console.log(document.querySelector('#table2 .el-table__body-wrapper tbody'))
  1447. const tbody = document.querySelector('#table2 .el-table__body-wrapper tbody')
  1448. // this.sorTable()
  1449. const that = this
  1450. // Sortable.create(tbody, {
  1451. var sortable = Sortable.create(tbody, {
  1452. disabled: that.dropState,
  1453. onChoose({ newIndex, oldIndex }) {
  1454. if (that.dropState == true) {
  1455. sortable.destroy()
  1456. }
  1457. },
  1458. onEnd({ newIndex, oldIndex }) {
  1459. const currRow = that.table2.list.splice(oldIndex, 1)[0]
  1460. that.table2.list.splice(newIndex, 0, currRow)
  1461. console.log('索引', newIndex)
  1462. console.log('拖动数据', currRow)
  1463. console.log('上', that.table2.list[newIndex - 1])
  1464. console.log('下', that.table2.list[newIndex + 1])
  1465. if (that.table2.list[newIndex - 1] === undefined) { // 拖动至最上方无值 // 顺序等于0,其他+1 // 饲料组等于饲料名称
  1466. for (let i = 0; i < that.table2.list.length; i++) {
  1467. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1 // 其他的顺序+1
  1468. }
  1469. currRow.sort = 0
  1470. currRow.feedgroup = currRow.fname
  1471. console.log('拖动至最上方无值')
  1472. } else if (currRow.sort == that.table2.list[newIndex - 1].sort) { // 拖动值顺序等于上值顺序
  1473. currRow.sort = that.table2.list[newIndex - 1].sort
  1474. console.log('拖动值顺序等于上值顺序')
  1475. } else if (that.table2.list[newIndex + 1] == undefined) { // 拖动至最下方无值 // 顺序等于上方顺序+1 // 饲料组等于饲料名称
  1476. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1477. currRow.feedgroup = currRow.fname
  1478. console.log('拖动至最下方无值')
  1479. } else if (currRow.sort == that.table2.list[newIndex + 1].sort) { // 拖动值顺序等于下值顺序
  1480. currRow.sort == that.table2.list[newIndex + 1].sort
  1481. console.log('拖动值顺序等于下值顺序')
  1482. } else if (that.table2.list[newIndex - 1].sort == that.table2.list[newIndex + 1].sort) { // 拖动至上下顺序一致,顺序/饲料组与上下保持一致
  1483. currRow.sort = that.table2.list[newIndex - 1].sort
  1484. currRow.feedgroup = that.table2.list[newIndex - 1].feedgroup
  1485. console.log('拖动至上下顺序一致')
  1486. } else if (that.table2.list[newIndex - 1].sort !== undefined && that.table2.list[newIndex + 1].sort !== undefined) { // 拖动至上下都有值
  1487. console.log('上下')
  1488. if (parseInt(that.table2.list[newIndex - 1].sort) + 1 == that.table2.list[newIndex + 1].sort) {
  1489. console.log(newIndex)
  1490. for (let i = newIndex; i < that.table2.list.length; i++) {
  1491. that.table2.list[i].sort = parseInt(that.table2.list[i].sort) + 1
  1492. }
  1493. }
  1494. currRow.sort = parseInt(that.table2.list[newIndex - 1].sort) + 1
  1495. currRow.feedgroup = currRow.fname
  1496. console.log(that.table2.list[newIndex + 1].sort)
  1497. }
  1498. that.requestParam = {}
  1499. that.requestParam.common = { 'returnmap': '0' }
  1500. that.requestParam.data = []
  1501. that.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': that.table2.list }}
  1502. that.requestParam.data[0].children = []
  1503. that.requestParam.data[0].children[0] = { 'name': 'updateFTdetailSort', 'type': 'e', 'parammaps': {
  1504. id: '@insertSpotList.id',
  1505. pastureid: '@insertSpotList.pastureid',
  1506. sort: '@insertSpotList.sort',
  1507. feedgroup: '@insertSpotList.feedgroup'
  1508. }}
  1509. ExecDataByConfig(that.requestParam).then(response => {
  1510. console.log('顺序切换保存发送参数', that.requestParam)
  1511. if (response.msg === 'fail') {
  1512. that.$notify({ title: '顺序切换失败', message: response.data, type: 'warning', duration: 2000 })
  1513. } else {
  1514. that.$notify({ title: '', message: '顺序切换成功', type: 'success', duration: 2000 })
  1515. that.getList2()
  1516. }
  1517. })
  1518. }
  1519. })
  1520. console.log(sortable.option('disabled'))
  1521. },
  1522. handleSearch2() {
  1523. console.log('点击了查询')
  1524. this.arrowDown2 = true
  1525. this.arrowUp2 = false
  1526. this.table2.getdataListParm.offset = 1
  1527. this.getList2()
  1528. },
  1529. handleRefresh2() {
  1530. console.log('点击了重置')
  1531. this.table2.getdataListParm.parammaps.fname = ''
  1532. this.table2.getdataListParm.parammaps.feedgroup = ''
  1533. this.table2.getdataListParm.parammaps.fweight = ''
  1534. this.table2.getdataListParm.parammaps.autosecondname = ''
  1535. this.table2.getdataListParm.parammaps.islockcount = '0'
  1536. this.table2.getdataListParm.parammaps.sort = ''
  1537. this.table2.getdataListParm.offset = 1
  1538. this.getList2()
  1539. },
  1540. // 详情新增
  1541. handleCreate2() {
  1542. console.log('点击了详情新增', this.table2.list)
  1543. // 编辑true/不可编辑false
  1544. // 新增操true,编辑false,编辑保存false
  1545. console.log(11)
  1546. for (let i = 0; i < this.table2.list.length; i++) {
  1547. if (this.table2.list[i].Edit === true) {
  1548. console.log(123)
  1549. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1550. return false
  1551. }
  1552. }
  1553. console.log(this.table2.list)
  1554. if (this.table2.list.length == 0) {
  1555. var mysort = 0
  1556. } else {
  1557. var mysort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1558. }
  1559. this.table2.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'groupEdit': false, 'groupNoEdit': true, 'enable': 1, 'feedgroup': '', 'fid': '', 'fname': '', 'fweight': '', 'autosecond': '0', 'islockcount': '0', 'sort': mysort })
  1560. console.log(this.table2.list)
  1561. },
  1562. changeFname(item, row) {
  1563. console.log(item, row)
  1564. this.table2.temp.fname = this.feedNameList.find(obj => obj.id == item).fname
  1565. row.fname = this.feedNameList.find(obj => obj.id == item).fname
  1566. if (this.feedNameList.find(obj => obj.id == item).ispreft == '0') {
  1567. this.table2.temp.preftid = '0'
  1568. } else {
  1569. this.table2.temp.preftid = item
  1570. }
  1571. if (row.sort == '') {
  1572. row.feedgroup = this.table2.temp.fname
  1573. } else {
  1574. if (row.isCreate == true) { // 新增状态下
  1575. for (let i = 1; i < this.table2.list.length; i++) {
  1576. if (this.table2.list[i].sort == row.sort) {
  1577. console.log(this.table2.list[i])
  1578. row.feedgroup = this.table2.list[i].feedgroup
  1579. break
  1580. } else {
  1581. row.feedgroup = this.table2.temp.fname
  1582. }
  1583. }
  1584. } else if (row.isUpdateSave == true) { // 编辑状态下
  1585. var Arr = []
  1586. for (let i = 0; i < this.table2.list.length; i++) {
  1587. Arr.push(this.table2.list[i].sort)
  1588. }
  1589. var Count = 0
  1590. for (let i = 0; i < Arr.length; i++) {
  1591. if (Arr[i] == row.sort) {
  1592. Count++
  1593. }
  1594. }
  1595. for (let i = 0; i < this.table2.list.length; i++) {
  1596. if (Count > 1) {
  1597. row.feedgroup = this.table2.list[i].feedgroup
  1598. console.log(111, this.table2.list[i].feedgroup)
  1599. break
  1600. } else if (Count == 1) {
  1601. row.feedgroup = this.table2.temp.fname
  1602. console.log(222, this.table2.temp.fname)
  1603. }
  1604. }
  1605. }
  1606. }
  1607. },
  1608. bort(row) {
  1609. if (row.isCreate == true) {
  1610. if (row.sort !== '') {
  1611. for (let i = 1; i < this.table2.list.length; i++) {
  1612. if (this.table2.list[i].sort == parseInt(row.sort)) {
  1613. row.feedgroup = this.table2.list[i].feedgroup
  1614. return false
  1615. } else {
  1616. row.feedgroup = row.fname
  1617. }
  1618. }
  1619. } else {
  1620. row.feedgroup = row.fname
  1621. }
  1622. } else if (row.isUpdateSave == true) {
  1623. if (row.sort !== '') {
  1624. for (let i = 0; i < this.table2.list.length; i++) {
  1625. if (this.table2.list[i].sort == row.sort) {
  1626. console.log('失去焦点,行内顺序与表格某顺序相同时', this.table2.list[i])
  1627. if (this.table2.list[i].id !== row.id) {
  1628. row.isGroupDisabled = true
  1629. row.feedgroup = this.table2.list[i].feedgroup
  1630. break
  1631. }
  1632. } else {
  1633. console.log('失去焦点,行内顺序与表格某顺序不相同时')
  1634. row.isGroupDisabled = true
  1635. row.feedgroup = row.fname
  1636. }
  1637. }
  1638. } else {
  1639. row.feedgroup = row.fname
  1640. }
  1641. }
  1642. },
  1643. createData2(row) {
  1644. console.log('点击了详情新增保存', row)
  1645. this.table2.temp.pastureid = Cookies.get('pastureid')
  1646. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1647. this.table2.temp.fid = row.fid
  1648. this.table2.temp.fname = this.table2.temp.fname
  1649. this.table2.temp.fweight = row.fweight
  1650. this.table2.temp.islockcount = row.islockcount
  1651. this.table2.temp.sort = row.sort
  1652. this.table2.temp.feedgroup = row.feedgroup
  1653. this.table2.temp.preftid = this.table2.temp.preftid
  1654. this.table2.temp.autosecond = row.autosecond
  1655. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1656. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1657. return false
  1658. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1659. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1660. return false
  1661. } else if (this.table2.temp.fid == '') {
  1662. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1663. return false
  1664. } else if (this.table2.temp.fweight == '') {
  1665. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1666. return false
  1667. } else if (this.table2.temp.autosecond == '') {
  1668. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1669. return false
  1670. }
  1671. if (this.table2.temp.sort !== '') {
  1672. this.table2.temp.sort = this.table2.temp.sort
  1673. } else {
  1674. console.log(this.table2.list.length)
  1675. if (this.table2.list.length == 1) {
  1676. this.table2.temp.sort = 0
  1677. } else {
  1678. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1679. row.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1680. }
  1681. }
  1682. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1683. if (parseInt(this.table2.temp.preftid) > 0) {
  1684. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1685. return false
  1686. }
  1687. }
  1688. // 校验顺序是否>=0
  1689. var ruleSort = /^\d+$/
  1690. if (!ruleSort.test(this.table2.temp.sort)) {
  1691. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1692. return false
  1693. }
  1694. // 检验重量>0
  1695. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1696. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1697. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1698. return false
  1699. }
  1700. this.isokDisable = true
  1701. setTimeout(() => {
  1702. this.isokDisable = false
  1703. }, 1000)
  1704. this.requestParam.common = { 'returnmap': '0' }
  1705. this.requestParam.data = []
  1706. this.requestParam.data[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  1707. pastureid: this.table2.temp.pastureid,
  1708. ftid: this.table2.getdataListParm.parammaps.ftid,
  1709. fid: row.fid,
  1710. fname: this.table2.temp.fname,
  1711. fweight: row.fweight,
  1712. islockcount: row.islockcount,
  1713. sort: row.sort,
  1714. feedgroup: row.feedgroup,
  1715. preftid: this.table2.temp.preftid,
  1716. autosecond: row.autosecond
  1717. }}
  1718. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1719. pastureid: this.table2.temp.pastureid,
  1720. ftid: this.table2.getdataListParm.parammaps.ftid,
  1721. type: this.table2.getdataListParm.parammaps.fttypeid
  1722. }}
  1723. ExecDataByConfig(this.requestParam).then(response => {
  1724. console.log('新增保存发送参数', this.requestParam)
  1725. if (response.msg !== 'fail') {
  1726. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1727. this.getList2()
  1728. } else {
  1729. failproccess(response, this.$notify)
  1730. }
  1731. })
  1732. },
  1733. createCancel2(row) {
  1734. console.log('点击了详情新增取消')
  1735. for (let i = 0; i < this.table2.list.length; i++) {
  1736. if (row.myId === this.table2.list[i].myId) {
  1737. var listIndex = this.table2.list.indexOf(this.table2.list[i])
  1738. }
  1739. if (listIndex > -1) {
  1740. this.table2.list.splice(listIndex, 1)
  1741. return
  1742. }
  1743. }
  1744. this.getDialogList()
  1745. },
  1746. // 详情编辑
  1747. handleUpdate2(row) {
  1748. console.log('详情编辑', row)
  1749. this.dropState = true
  1750. row.isGroupDisabled = false
  1751. row.islockcount = String(row.islockcount)
  1752. row.fid = String(row.fid)
  1753. row.autosecond = String(row.autosecond)
  1754. this.table2.temp.fname = row.fname
  1755. this.table2.temp.preftid = row.preftid
  1756. const rowArr = []
  1757. for (let i = 0; i < this.table2.list.length; i++) {
  1758. if (this.table2.list[i].Edit == true) {
  1759. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  1760. return false
  1761. }
  1762. rowArr.push(this.table2.list[i].sort)
  1763. }
  1764. var count = 0
  1765. for (let i = 0; i < rowArr.length; i++) {
  1766. if (rowArr[i] == row.sort) {
  1767. count++
  1768. }
  1769. }
  1770. // 判断是否有相同顺序,如果没有饲料组不可编辑,若有饲料组可编辑
  1771. if (count == 1) {
  1772. // 饲料组编辑false,不可编辑true
  1773. row.groupEdit = false
  1774. row.groupNoEdit = true
  1775. // 编辑true,不可编辑false
  1776. row.Edit = true
  1777. row.NoEdit = false
  1778. // 新增false,编辑false,编辑保存true
  1779. row.isCreate = false
  1780. row.isUpdate = false
  1781. row.isUpdateSave = true
  1782. } else if (count > 1) {
  1783. // 饲料组编辑true,不可编辑false
  1784. row.groupEdit = true
  1785. row.groupNoEdit = false
  1786. console.log(222)
  1787. // 编辑true,不可编辑false
  1788. row.Edit = true
  1789. row.NoEdit = false
  1790. // 新增false,编辑false,编辑保存true
  1791. row.isCreate = false
  1792. row.isUpdate = false
  1793. row.isUpdateSave = true
  1794. return false
  1795. }
  1796. },
  1797. updateData2(row) {
  1798. console.log('点击了详情编辑保存111', row)
  1799. this.isokDisable = true
  1800. setTimeout(() => {
  1801. this.isokDisable = false
  1802. }, 1000)
  1803. this.table2.temp.pastureid = row.pastureid
  1804. this.table2.temp.ftid = this.table2.getdataListParm.parammaps.ftid
  1805. this.table2.temp.fid = row.fid
  1806. this.table2.temp.fname = this.table2.temp.fname
  1807. this.table2.temp.fweight = row.fweight
  1808. this.table2.temp.islockcount = row.islockcount
  1809. this.table2.temp.sort = row.sort
  1810. this.table2.temp.feedgroup = row.feedgroup
  1811. this.table2.temp.preftid = this.table2.temp.preftid
  1812. this.table2.temp.autosecond = row.autosecond
  1813. this.table2.temp.id = row.id
  1814. if (this.table2.temp.fid == '' && this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1815. this.$message({ type: 'error', message: '饲料名称/重量/搅拌延时不能为空', duration: 2000 })
  1816. return false
  1817. } else if (this.table2.temp.fweight == '' && this.table2.temp.autosecond == '') {
  1818. this.$message({ type: 'error', message: '重量/搅拌延时不能为空', duration: 2000 })
  1819. return false
  1820. } else if (this.table2.temp.fid == '') {
  1821. this.$message({ type: 'error', message: '饲料名称不能为空', duration: 2000 })
  1822. return false
  1823. } else if (this.table2.temp.fweight == '') {
  1824. this.$message({ type: 'error', message: '重量不能为空', duration: 2000 })
  1825. return false
  1826. } else if (this.table2.temp.autosecond == '') {
  1827. this.$message({ type: 'error', message: '搅拌延时不能为空', duration: 2000 })
  1828. return false
  1829. }
  1830. if (this.table2.temp.sort !== '') {
  1831. this.table2.temp.sort = this.table2.temp.sort
  1832. } else {
  1833. this.table2.temp.sort = parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1
  1834. }
  1835. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  1836. if (parseInt(this.table2.temp.preftid) > 0) {
  1837. this.$message({ type: 'error', message: '饲料名称不能选择预混配方', duration: 2000 })
  1838. return false
  1839. }
  1840. }
  1841. // 校验顺序是否>=0
  1842. var ruleSort = /^\d+$/
  1843. if (!ruleSort.test(this.table2.temp.sort)) {
  1844. this.$message({ type: 'error', message: '饲料顺序不可为负数或小数', duration: 2000 })
  1845. return false
  1846. }
  1847. // 检验重量>0
  1848. var ruleWeight = /(^[1-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
  1849. if (!ruleWeight.test(this.table2.temp.fweight)) {
  1850. this.$message({ type: 'error', message: '重量请输入正数,最多保留俩位小数', duration: 2000 })
  1851. return false
  1852. }
  1853. this.requestParam.common = { 'returnmap': '0' }
  1854. this.requestParam.data = []
  1855. this.requestParam.data[0] = { 'name': 'updateFTdetail', 'type': 'e', 'parammaps': {
  1856. pastureid: row.pastureid,
  1857. ftid: this.table2.getdataListParm.parammaps.ftid,
  1858. fid: row.fid,
  1859. fname: this.table2.temp.fname,
  1860. fweight: row.fweight,
  1861. islockcount: row.islockcount,
  1862. sort: row.sort,
  1863. feedgroup: row.feedgroup,
  1864. preftid: this.table2.temp.preftid,
  1865. autosecond: row.autosecond,
  1866. id: row.id
  1867. }}
  1868. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1869. pastureid: row.pastureid,
  1870. ftid: this.table2.getdataListParm.parammaps.ftid,
  1871. type: this.table2.getdataListParm.parammaps.fttypeid
  1872. }}
  1873. this.requestParam.data[2] = { 'name': 'updateFTdetailbySort', 'type': 'e', 'parammaps': {
  1874. pastureid: row.pastureid,
  1875. ftid: this.table2.getdataListParm.parammaps.ftid,
  1876. sort: row.sort,
  1877. feedgroup: row.feedgroup
  1878. }}
  1879. ExecDataByConfig(this.requestParam).then(response => {
  1880. console.log('新增保存发送参数', this.requestParam)
  1881. if (response.msg !== 'fail') {
  1882. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1883. this.getList2()
  1884. this.dropState = false
  1885. } else {
  1886. failproccess(response, this.$notify)
  1887. }
  1888. })
  1889. },
  1890. updateCancel2(row) {
  1891. console.log('点击了详情编辑取消')
  1892. // 饲料组编辑false,不可编辑true
  1893. row.groupEdit = false
  1894. row.groupNoEdit = true
  1895. // 编辑false,不可编辑true
  1896. row.Edit = false
  1897. row.NoEdit = true
  1898. // 新增false,编辑true,编辑保存false
  1899. row.isCreate = false
  1900. row.isUpdate = true
  1901. row.isUpdateSave = false
  1902. this.getList2()
  1903. this.dropState = false
  1904. },
  1905. // 详情删除
  1906. handleRowDelete2(row) {
  1907. console.log('点击了行内删除')
  1908. MessageBox.confirm('是否确认删除此信息?', {
  1909. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1910. }).then(() => {
  1911. this.requestParam.common = { 'returnmap': '0' }
  1912. this.requestParam.data = []
  1913. this.requestParam.data[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1914. pastureid: row.pastureid,
  1915. id: row.id
  1916. }}
  1917. this.requestParam.data[1] = { 'name': 'updateFPbyFTChange', 'type': 'e', 'parammaps': {
  1918. pastureid: row.pastureid,
  1919. ftid: this.table2.getdataListParm.parammaps.ftid,
  1920. type: this.table2.getdataListParm.parammaps.fttypeid
  1921. }}
  1922. ExecDataByConfig(this.requestParam).then(response => {
  1923. console.log('新增保存发送参数', this.requestParam)
  1924. if (response.msg === 'fail') {
  1925. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1926. } else {
  1927. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  1928. this.getList2()
  1929. }
  1930. })
  1931. }).catch(() => {
  1932. this.$message({ type: 'info', message: '已取消删除' })
  1933. })
  1934. },
  1935. handleSelectionChange2(val) {
  1936. console.log('勾选数据', val)
  1937. this.selectList2 = val
  1938. },
  1939. handleDelete2() {
  1940. console.log('点击了删除')
  1941. if (this.selectList2.length == 0) {
  1942. this.$message({ type: 'error', message: '请选择配方详情', duration: 2000 })
  1943. } else {
  1944. MessageBox.confirm('是否确认删除此信息?', {
  1945. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  1946. }).then(() => {
  1947. console.log(this.selectList)
  1948. this.requestParam.common = { 'returnmap': '0' }
  1949. this.requestParam.data = []
  1950. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList2 }}
  1951. this.requestParam.data[0].children = []
  1952. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  1953. id: '@insertSpotList.id',
  1954. pastureid: '@insertSpotList.pastureid'
  1955. }}
  1956. ExecDataByConfig(this.requestParam).then(response => {
  1957. console.log('删除保存发送参数', this.requestParam)
  1958. if (response.msg === 'fail') {
  1959. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  1960. } else {
  1961. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  1962. this.getList2()
  1963. }
  1964. })
  1965. })
  1966. }
  1967. },
  1968. // 拆分预混料
  1969. handleSplitPremix(row) {
  1970. console.log('点击了拆分预混料')
  1971. MessageBox.confirm('是否确认拆分当前预混料?', {
  1972. confirmButtonText: '确认',
  1973. cancelButtonText: '取消',
  1974. type: 'warning'
  1975. }).then(() => {
  1976. this.requestParam.name = 'splitFTpre'
  1977. this.requestParam.parammaps = {}
  1978. this.requestParam.parammaps.ftid = this.table2.getdataListParm.parammaps.ftid
  1979. this.requestParam.parammaps.preftid = row.preftid
  1980. this.requestParam.parammaps.ftdid = row.id
  1981. this.requestParam.parammaps.pastureid = row.pastureid
  1982. this.requestParam.parammaps.feedgroup = row.feedgroup
  1983. this.requestParam.parammaps.sort = row.sort
  1984. this.requestParam.parammaps.fweight = row.fweight
  1985. PostDataByName(this.requestParam).then(response => {
  1986. if (response.msg === 'fail') {
  1987. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  1988. } else {
  1989. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  1990. this.getList2()
  1991. }
  1992. })
  1993. }).catch(() => {
  1994. this.$message({
  1995. type: 'info',
  1996. message: '已取消删除'
  1997. })
  1998. })
  1999. },
  2000. // 合成预混料
  2001. handleSyntheticPremix() {
  2002. console.log('点击了合成预混料', this.selectList2)
  2003. if (this.table2.getdataListParm.parammaps.fttypeid == 2) {
  2004. this.$message({ type: 'error', message: '预混配方不可合成预混料', duration: 2000 })
  2005. return false
  2006. } else {
  2007. if (this.selectList2.length > 1) {
  2008. for (let i = 0; i < this.selectList2.length; i++) {
  2009. if (parseInt(this.selectList2[i].preftid) > 0) {
  2010. this.$message({ type: 'error', message: '不可选择预混料', duration: 2000 })
  2011. return false
  2012. }
  2013. }
  2014. if (this.selectList2[0].splitftpreid !== undefined) {
  2015. this.detail.getdataListParm.parammaps.ftid = this.selectList2[0].splitftpreid
  2016. this.detail.getdataListParm.parammaps.pastureid = this.selectList2[0].pastureid
  2017. GetDataByName(this.detail.getdataListParm).then(response => {
  2018. if (response.data.list !== null) { // 不为空时得到比对数据
  2019. this.detail.list3 = response.data.list
  2020. const sortList = [] // 声明排序数组
  2021. var fweightSum = 0 // 总重量
  2022. for (let i = 0; i < this.selectList2.length; i++) {
  2023. const obj = {}
  2024. obj.fid = this.selectList2[i].fid
  2025. obj.fweight = this.selectList2[i].fweight
  2026. fweightSum = fweightSum + parseFloat(this.selectList2[i].fweight)
  2027. sortList.push(obj)
  2028. }
  2029. // 排序
  2030. sortList.sort(function(a, b) {
  2031. return a.fid.localeCompare(b.fid)
  2032. })
  2033. var a = 0
  2034. if (this.detail.list3.length == sortList.length) {
  2035. for (let i = 0; i < this.detail.list3.length; i++) {
  2036. if (this.detail.list3[i].fid == sortList[i].fid && (this.detail.list3[i].fweight / this.detail.list3[i].sumWeight).toFixed(2) == (sortList[i].fweight / fweightSum).toFixed(2)) {
  2037. a++
  2038. }
  2039. }
  2040. if (a == this.detail.list3.length) { // 如果相等,则该配方为原预混配方
  2041. this.detail.getdataListParm2.parammaps.ftid = this.selectList2[0].splitftpreid
  2042. this.detail.getdataListParm2.parammaps.pastureid = this.selectList2[0].pastureid
  2043. GetDataByName(this.detail.getdataListParm2).then(response => {
  2044. if (response.data.list !== null) {
  2045. this.detail.dialogStatus = 'SyntheticPremix'
  2046. this.detail.dialogFormVisible = true
  2047. this.detail.list = this.selectList2
  2048. this.detail.list2 = response.data.list
  2049. this.detail.disabled = true
  2050. setTimeout(() => {
  2051. this.detail.listLoading = false
  2052. }, 100)
  2053. } else {
  2054. this.detail.list2 = []
  2055. }
  2056. })
  2057. } else {
  2058. this.detail.dialogStatus = 'SyntheticPremix'
  2059. this.detail.dialogFormVisible = true
  2060. this.detail.list = this.selectList2
  2061. this.detail.disabled = false
  2062. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2063. setTimeout(() => {
  2064. this.detail.listLoading = false
  2065. }, 100)
  2066. }
  2067. } else {
  2068. this.detail.dialogStatus = 'SyntheticPremix'
  2069. this.detail.dialogFormVisible = true
  2070. this.detail.list = this.selectList2
  2071. this.detail.disabled = false
  2072. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2073. setTimeout(() => {
  2074. this.detail.listLoading = false
  2075. }, 100)
  2076. }
  2077. } else {
  2078. this.detail.list3 = []
  2079. this.detail.dialogStatus = 'SyntheticPremix'
  2080. this.detail.dialogFormVisible = true
  2081. this.detail.list = this.selectList2
  2082. this.detail.disabled = false
  2083. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2084. setTimeout(() => {
  2085. this.detail.listLoading = false
  2086. }, 100)
  2087. }
  2088. })
  2089. } else {
  2090. this.detail.dialogStatus = 'SyntheticPremix'
  2091. this.detail.dialogFormVisible = true
  2092. this.detail.list = this.selectList2
  2093. this.detail.disabled = false
  2094. this.detail.list2 = [{ tname: '', tcolor: '#ccc', ccid: '', fttype: '预混配方', fttypeid: '2', source: '自定义', remark: '', 'enable': 1 }]
  2095. setTimeout(() => {
  2096. this.detail.listLoading = false
  2097. }, 100)
  2098. }
  2099. } else {
  2100. this.$message({ type: 'error', message: '请选择俩条及以上饲料进行合成', duration: 2000 })
  2101. return false
  2102. }
  2103. }
  2104. },
  2105. // 畜生类别
  2106. changeLivestockType2(item) {
  2107. this.detail.list2[0].ccname = this.livestockTypeList.find(obj => obj.value === item).label
  2108. },
  2109. syntheticPremixData() {
  2110. console.log('点击了合成预混料确认')
  2111. if (this.detail.disabled == true) { // 原预混料
  2112. let sumFweight = 0
  2113. for (let i = 0; i < this.detail.list.length; i++) {
  2114. sumFweight += parseFloat(this.detail.list[i].fweight)
  2115. }
  2116. sumFweight = sumFweight.toFixed(2)
  2117. this.isokDisable = true
  2118. setTimeout(() => {
  2119. this.isokDisable = false
  2120. }, 1000)
  2121. this.requestParam.common = { 'returnmap': '0' }
  2122. this.requestParam.data = []
  2123. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2124. this.requestParam.data[0].children = []
  2125. this.requestParam.data[0].children[0] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2126. pastureid: '@insertSpotList.pastureid',
  2127. id: '@insertSpotList.id'
  2128. }}
  2129. this.requestParam.data[1] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2130. this.requestParam.data[1].children = []
  2131. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2132. pastureid: Cookies.get('pastureid'),
  2133. ftid: this.table2.getdataListParm.parammaps.ftid,
  2134. fid: this.detail.list2[0].id,
  2135. fname: '@insertSpotList2.tname',
  2136. fweight: sumFweight,
  2137. islockcount: '0',
  2138. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2139. feedgroup: '@insertSpotList2.tname',
  2140. preftid: this.detail.list2[0].id,
  2141. autosecond: this.detail.list[0].autosecond
  2142. }}
  2143. ExecDataByConfig(this.requestParam).then(response => {
  2144. console.log('合成预混料保存发送参数', this.requestParam)
  2145. if (response.msg === 'fail') {
  2146. const tname = new RegExp("key 'tname'")
  2147. if (tname.test(response.data)) {
  2148. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2149. } else {
  2150. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2151. }
  2152. } else {
  2153. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2154. this.detail.dialogFormVisible = false
  2155. this.getList()
  2156. this.getList2()
  2157. this.getDownList()
  2158. }
  2159. })
  2160. } else { // 现生成预混料
  2161. if (this.detail.list2[0].tname == '' && this.detail.list2[0].ccid == '') {
  2162. this.$message({ type: 'error', message: '配方名称/牲畜类别/不能为空', duration: 2000 })
  2163. return false
  2164. } else if (this.detail.list2[0].tname == '') {
  2165. this.$message({ type: 'error', message: '配方名称不能为空', duration: 2000 })
  2166. return false
  2167. } else if (this.detail.list2[0].ccid == '') {
  2168. this.$message({ type: 'error', message: '牲畜类别不能为空', duration: 2000 })
  2169. return false
  2170. }
  2171. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2172. if (pattern.test(this.detail.list2[0].tname)) {
  2173. this.$message({ type: 'error', message: '配方名称不可输入特殊字符', duration: 2000 })
  2174. return false
  2175. }
  2176. let sumFweight = 0
  2177. for (let i = 0; i < this.detail.list.length; i++) {
  2178. sumFweight += parseFloat(this.detail.list[i].fweight)
  2179. }
  2180. sumFweight = sumFweight.toFixed(2)
  2181. console.log(sumFweight)
  2182. this.isokDisable = true
  2183. setTimeout(() => {
  2184. this.isokDisable = false
  2185. }, 1000)
  2186. if (this.detail.list2[0].tcolor == null) {
  2187. this.detail.list2[0].tcolor = '#CCCCCC'
  2188. }
  2189. this.requestParam.common = { 'returnmap': '0' }
  2190. this.requestParam.data = []
  2191. this.requestParam.data[0] = { 'name': 'insertFT', 'type': 'e', 'parammaps': {
  2192. pastureid: Cookies.get('pastureid'),
  2193. tcode: this.detail.list2[0].tcode,
  2194. tname: this.detail.list2[0].tname,
  2195. tcolor: this.detail.list2[0].tcolor,
  2196. ccid: this.detail.list2[0].ccid,
  2197. ccname: this.detail.list2[0].ccname,
  2198. fttype: this.detail.list2[0].fttype,
  2199. fttypeid: this.detail.list2[0].fttypeid,
  2200. source: this.detail.list2[0].source,
  2201. remark: this.detail.list2[0].remark,
  2202. enable: this.detail.list2[0].enable
  2203. }}
  2204. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.detail.list }}
  2205. this.requestParam.data[1].children = []
  2206. this.requestParam.data[1].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2207. pastureid: '@insertSpotList.pastureid',
  2208. ftid: '@insertFT.LastInsertId',
  2209. fid: '@insertSpotList.fid',
  2210. fname: '@insertSpotList.fname',
  2211. fweight: '@insertSpotList.fweight',
  2212. islockcount: '@insertSpotList.islockcount',
  2213. sort: '@insertSpotList.sort',
  2214. feedgroup: '@insertSpotList.feedgroup',
  2215. preftid: '@insertSpotList.preftid',
  2216. autosecond: '@insertSpotList.autosecond'
  2217. }}
  2218. this.requestParam.data[1].children[1] = { 'name': 'deleteFTdetail', 'type': 'e', 'parammaps': {
  2219. pastureid: '@insertSpotList.pastureid',
  2220. id: '@insertSpotList.id'
  2221. }}
  2222. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.detail.list2 }}
  2223. this.requestParam.data[2].children = []
  2224. this.requestParam.data[2].children[0] = { 'name': 'insertFTdetail', 'type': 'e', 'parammaps': {
  2225. pastureid: Cookies.get('pastureid'),
  2226. ftid: this.table2.getdataListParm.parammaps.ftid,
  2227. fid: '@insertFT.LastInsertId',
  2228. fname: '@insertSpotList2.tname',
  2229. fweight: sumFweight,
  2230. islockcount: '0',
  2231. sort: parseInt(this.table2.list[this.table2.list.length - 1].sort) + 1,
  2232. feedgroup: '@insertSpotList2.tname',
  2233. preftid: '@insertFT.LastInsertId',
  2234. autosecond: this.detail.list[0].autosecond
  2235. }}
  2236. ExecDataByConfig(this.requestParam).then(response => {
  2237. console.log('合成预混料保存发送参数', this.requestParam)
  2238. if (response.msg === 'fail') {
  2239. const tname = new RegExp("key 'tname'")
  2240. if (tname.test(response.data)) {
  2241. this.$message({ type: 'error', message: '预混配方已存在,不可重复生成', duration: 2000 })
  2242. } else {
  2243. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  2244. }
  2245. } else {
  2246. this.$notify({ title: '', message: '保存成功', type: 'success', duration: 2000 })
  2247. this.detail.dialogFormVisible = false
  2248. this.getList()
  2249. this.getList2()
  2250. this.getDownList()
  2251. }
  2252. })
  2253. }
  2254. }
  2255. }
  2256. }
  2257. </script>
  2258. <style lang="scss" scoped>
  2259. .search{margin-top:10px;}
  2260. .table{margin-top:10px;}
  2261. .table2{margin-top:10px;}
  2262. $width:350px;
  2263. $left:325px;
  2264. .selectInput{
  2265. position: relative;
  2266. display: inline-block;
  2267. .Input{width: $width;position: relative;}
  2268. .el-icon-arrow-down{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2269. .el-icon-arrow-up{width: 30px;height: 30px;position: absolute;left: $left;top:10px;color:#C0C4CC;}
  2270. .selectUl{
  2271. z-index: 111;width: $width;background: #fff;border: 1px solid #E4E7ED;box-shadow: 0 2px 12px 0 rgba(0,0,0,.1);margin: -1px 0 0 0;padding: 6px 0; margin: 0;box-sizing: border-box;position: absolute;
  2272. li{
  2273. list-style: none;font-size: 14px; padding: 0 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #606266; height: 50px; line-height: 50px; box-sizing: border-box; cursor: pointer;
  2274. a{float:left;width: 80px;}
  2275. a:hover{color: rgba(0, 204, 102, 0.71); font-weight: 700;}
  2276. }
  2277. }
  2278. }
  2279. .template{
  2280. background: #fff;
  2281. position: relative;
  2282. .recipeTemplate{
  2283. width: 72px;
  2284. height: 70px;
  2285. position: absolute;
  2286. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2287. right: 0;
  2288. top: 0;
  2289. margin: 0;
  2290. }
  2291. }
  2292. .detail{
  2293. background: #fff;
  2294. position: relative;
  2295. .recipeDetail{
  2296. width: 72px;
  2297. height: 70px;
  2298. position: absolute;
  2299. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2300. right: 0;
  2301. top: 0;
  2302. margin: 0;
  2303. }
  2304. }
  2305. .templateDialog{
  2306. background: #fff;
  2307. position: relative;
  2308. .recipeTemplate{
  2309. width: 72px;
  2310. height: 70px;
  2311. position: absolute;
  2312. background: url(../../../assets/images/bg1.jpg) no-repeat;
  2313. right: 0;
  2314. top: 0;
  2315. margin: 0;
  2316. }
  2317. }
  2318. .detailDialog{
  2319. background: #fff;
  2320. position: relative;
  2321. .recipeDetail{
  2322. width: 72px;
  2323. height: 70px;
  2324. position: absolute;
  2325. background: url(../../../assets/images/bg2.jpg) no-repeat;
  2326. right: 0;
  2327. top: 0;
  2328. margin: 0;
  2329. }
  2330. }
  2331. </style>